Android Question read a jpeg image from a string

Addo

Well-Known Member
Licensed User
Longtime User
i have this iage that i save it into a data base as string using delphi

B4X:
/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4pLSwzOko+MzZGNywtQFdBRkxOUlNSMj5aYVpQYEpRUk//2wBDAQ4ODhMREyYVFSZPNS01T09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0//wgARCACmAKYDASIAAhEBAxEB/8QAGgAAAgMBAQAAAAAAAAAAAAAAAAIBBAUDBv/EABgBAQEBAQEAAAAAAAAAAAAAAAABAgME/9oADAMBAAIQAxAAAAHXVlgJBQBYdR3RxgCUbkrSCSLyOxABAsrLIL2g5R2VecMqMyyPBA1axWm36rFzRv5OzZEMsQSKvTnKMrscnhSIIGmHJhlEoNmVorRsmlZklhXgQYEmJQaIICRACXVivPJVjz+/5uyxZ4XF9CKQ6xxjscwhubkyrVAMnKeig6ca5YG/RKdGxXl69qlo9J3x9KuiMkMBLASkurVEgHPopyzNnLs4VoISe9tujZt8MWjZjlqadmhpXMASq/NkdlaoIlAmsVMyOVqcvRZZVGtRz4vaKXUYnd85pVrEGaMr2TMiLJBObfzFoVLs6np/Leow83Nv5sy7lTO5pGvmegrAs59vU9EQY10aZuVloWF6IiYmrm1n7nnPZHXMt18a8l22MEs152dTlvw0eTtR01NU5Gdd0ed4RpgUkOfnfS4hX0c4l3nybvLu2bp9988m1eN80O0S5ehW747QdTfGQLkUFlQszs0M6noBUsBHoXDeWrhLcqB5+5ZDOuQHq83/xAArEAACAQMDAwMEAgMAAAAAAAABAgMABBESEyAQISIjMDEFJDNBFDIVNED/2gAIAQEAAQUC/wCPPsjk39uhNQuZIzzxxHB/yn81XbeKDCngOB9h/wA1alxAd654joeh5GiwUHIpZSYmLGK3j24ueOQ6Gr1QbdPBNbKAS/s56ngzHd7h74fbajWo4tjruPfnIjMdwJFu29CgpaOxQB+h6Dn++t9/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IiBB0HgygFCVigpVKRgc5JGG3zvn94iNH5wnLgUfP9/nNztOJkALef7+MtB5XnKBi4AJQFUhry5t4HR48YJDRIbK00/W/rKBW3YcQ37vHswYVMzYrrc6hs5fWIYkt0UaHyP2XeOCLAojZo2o1qyeMRggOR06QHysP946yD/f7+c8YDN8zGItBZLOlbOPCibxrII8KDhZ2411lJAnAAj97ee/nF7bzRj5mCSn84JIIrPWCp7Jjvi7BhIAJQUrBuBHfFRn1/8APelooDpo9YIQZQ4HeEwa1TTjXjBFg6j5N71lJA26yITRc2xDjvBYjEfzg2SRWglOLxsx7aMY7gePeBxCxQtFtPd/L5bCz0a8103+phFjXt5/pn//2Q==


that's how i save this image to string

B4X:
var
Jpg: TJPEGImage;
JpegStream: TMemoryStream;
stringimage : string;
begin
JpegStream := TMemoryStream.Create;
try
Jpg := TJPEGImage.Create;
try

Jpg.Performance := jpBestSpeed;
Jpg.ProgressiveEncoding := True;
Jpg.ProgressiveDisplay := True;
Jpg.Assign(image2.Picture.Bitmap);
Jpg.CompressionQuality := 60;
Jpg.Compress;

Jpg.SaveToStream(JpegStream);



finally
Jpg.Free;
end;
JpegStream.Position := 0;
stringimage := TIdEncoderMIME.EncodeStream(JpegStream);// this is the actual image to string
finally
JpegStream.Free;
end;

end;

that how i retrieve the string back to the actual image


B4X:
var
  JpegStream: TMemoryStream;
  JpegImage: TJPEGImage;
begin

JpegImage := TJpegImage.Create;
try
JpegStream := TMemoryStream.Create;
try
TIdDecoderMIME.DecodeStream(stringimage, JpegStream);
JpegStream.Position := 0;
JpegImage.LoadFromStream(JpegStream);
image3.Picture.Assign(JpegImage);
finally
JpegStream.Free;
end;

finally
JpegImage.Free;
end;

end;

i know this is encoded to base64 but i am not sure how to read it in b4a correctly in image view
 

moster67

Expert
Licensed User
Longtime User
Something like this perhaps:

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
 
    Dim str As String = "yourbase64 string"
    Dim stut As StringUtils 'make sure you've added StringUtils lib to your project
    Dim imgbyte() As Byte = stut.DecodeBase64(str)
    Dim bmp As Bitmap = BytesToImage(imgbyte)
    'do what you want with the bitmap (bmp)
End Sub


Public Sub BytesToImage(bytes() As Byte) As Bitmap
    Dim In As InputStream
    In.InitializeFromBytesArray(bytes, 0, bytes.Length)
    Dim bmp As Bitmap
    bmp.Initialize2(In)
    In.Close
    Return bmp
End Sub
 
Last edited:
Upvote 0

Addo

Well-Known Member
Licensed User
Longtime User
that was great example to learn i have tried to re encode the image to base64 like following

B4X:
        Dim imagetostring As String
    Dim imgbyets() As Byte
   
    imgbyets =  imagetobyets(bmp)
   
    imagetostring = stut.EncodeBase64(imgbyets)
   
    Log(imagetostring)


Public Sub imagetobyets(img As Bitmap) As Byte()
Dim out As OutputStream
out.InitializeToBytesArray(0)
img.WriteToStream(out, 70, "JPEG")
out.Close
Dim data() As Byte = out.ToBytesArray
Return data
End Sub

but the image comes out in half gray and the base64 string is different from the previews encode
B4X:
/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIfIiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/2wBDAQoLCw4NDhwQEBw7KCIoOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozv/wAARCACmAKYDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+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mNK0y5sZI5pRJbm3BjeNUMfz4yNhOQZCeH9B9YqN20E9tCquh6hMkUjEMl2MRZkQY6ScEvxwc846j1FSQeGdUjR44bWe4WTGUtJ0lKevyRk8ds49PWtHT/EmiPcaAXvJkuLOSM3HmRlYdojROMuef3fXAzkelbmp+I9D1KyuUvby2lRIJJYcvv2SN5eAoHz8Pv7dPalJ2qJI6adNOk5M5u28MSCSM3dhdQRhHMkbxvESARxwhPPPQetbB8Jy6RYz21trs0z3EDxXCfZ3MBDgHJfoD0OfbGRW34cNvaT31pHeQzRLNH/pFuQiEeS

what could be my mistake ?
 
Last edited:
Upvote 0

OliverA

Expert
Licensed User
Longtime User
string is different from the previews encode
bmp.Initialize2(In)
This takes your JPEG image and converts it to an object of type Bitmap that has a different "layout" than a JPEG (https://developer.android.com/reference/android/graphics/Bitmap.Config.html)(most likely ARGB_8888, see link)
img.WriteToStream(out, 70, "JPEG")
It's re-encoding your image to another JPEG at quality of 70. So this is the second conversion done to your original source. The end result is going to be different. If you want to keep the original file, then keep the original byte array or Base64 encoded string.

Note: In B4J, your source image seemed to display fine (your avatar).
 
Upvote 0

Addo

Well-Known Member
Licensed User
Longtime User
Hello Oliver the problem is using any other image to encode it to a base64 string its not complete
Not only the decoded image

Any image I try to encode to base64 string came out in a half gray when I try to decode it

 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
what could be my mistake ?
You're logging the string (I'm guessing here) and then copying your log output. Well, the log output truncates the Base64 string (it does not show the complete string). From the looks of it, it cuts off about half (therefore, you only see half and the rest is gray/missing). Please note that only the log output is truncated, the actual string variable contains the whole encoded string.
 
Upvote 0

Addo

Well-Known Member
Licensed User
Longtime User

wow i start to believe that i am a mental retarded yes that was the case i was copy the logging data which is incomplete because the string is too big
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…