narek adonts Well-Known Member Licensed User Longtime User Aug 19, 2015 #1 Hi, I am using this Sub to convert a bitmap to bytes. Code: Copy Sub BitmapToBytes(Image As Bitmap) As Byte() Dim out As OutputStream Dim bb() As Byte out.InitializeToBytesArray(0) Image.WriteToStream(out,100,"JPEG") out.Close bb=out.ToBytesArray Log(bb.Length) Return bb End Sub The strange thing is for a Image of 1MB after converting to bytes it become 3.4MB Can someone check it please and advise a solution. Thank you.
Hi, I am using this Sub to convert a bitmap to bytes. Code: Copy Sub BitmapToBytes(Image As Bitmap) As Byte() Dim out As OutputStream Dim bb() As Byte out.InitializeToBytesArray(0) Image.WriteToStream(out,100,"JPEG") out.Close bb=out.ToBytesArray Log(bb.Length) Return bb End Sub The strange thing is for a Image of 1MB after converting to bytes it become 3.4MB Can someone check it please and advise a solution. Thank you.
JanPRO Well-Known Member Licensed User Longtime User Aug 20, 2015 #2 I think it happends, because JPEG is a compressed graphic format. Your code looks fine Upvote 0
narek adonts Well-Known Member Licensed User Longtime User Aug 20, 2015 #3 Yes but if it compressed it should be less not 3 times more. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Aug 20, 2015 #4 The only way to change the size is by reducing the quality. However if you have access to the original file then you can use it instead. The actual conversion is done with a call to UIImageJPEGRepresentation API. Upvote 0
The only way to change the size is by reducing the quality. However if you have access to the original file then you can use it instead. The actual conversion is done with a call to UIImageJPEGRepresentation API.
narek adonts Well-Known Member Licensed User Longtime User Aug 20, 2015 #5 the problem is that I want to use the same image size as it is. When I am trying to send the image by Mail app it says that actual size is 1MB when trying to convert the same image to bytes with UIImageJPEGRepresentation the Bytes length is more then 3MB. Upvote 0
the problem is that I want to use the same image size as it is. When I am trying to send the image by Mail app it says that actual size is 1MB when trying to convert the same image to bytes with UIImageJPEGRepresentation the Bytes length is more then 3MB.