1. Black Friday Sale - 50% off

    B4A Standard for $29 instead of $59!
    Buy Now
    Dismiss Notice

Android Question How to convert bitmap to raw byte[] ?

Discussion in 'Android Questions' started by Marcob, Jul 28, 2018.

  1. Marcob

    Marcob Member Licensed User


    I'm aware that a bitmap can be converted to a compressed PNG/JPEG data array for example by using bitmap.WriteToStream(). Does a way for getting just an uncompressed data array from a bitmap exist?
  2. MarkusR

    MarkusR Well-Known Member Licensed User

    Erel likes this.
  3. Marcob

    Marcob Member Licensed User

    Thank you MarkusR, I'll try getPixels(bmp,dst,0,bmp.Width,0,0,bmp.Width,bmp.Height) from BitmapExtended lib
    MarkusR likes this.
  4. Star-Dust

    Star-Dust Expert Licensed User

    Public Sub BitmapToByte (SourceBitmap As BitmapAs Byte()
    Dim mBuffer() As Byte
    Dim jo As JavaObject = SourceBitmap
    Dim format As Object = jo.RunMethod("getConfig"Null)
    If "ARGB_8888" <> format Then
    Log("Unsupported format: " & format)
    End If
    Dim bf As JavaObject
        bf = bf.InitializeStatic(
    Return mBuffer
    End Sub
    Johan Hormaza likes this.
  5. Erel

    Erel Administrator Staff Member Licensed User

    You should use BitmapCreator for this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice