Kostya (or anyone else)

Ok. In TRYING to write out a  ANDROID Bitmap to a windows .bmp file.
I am very close but there is something that is still off because my image
doesn't look right (as in the screen shot below).

Here is how I am writing out to the file:

cache - is the Android Bitmap file which I want to write out to a .bmp file.

It is  set to:  Bitmap.Config.ARGB_8888

                           //Get the Bitmap height, width, and put the data
into a byte array (bytesar)

                            byte[]   bytesar   = null;
                            ByteBuffer  dst   = null;

                            int height = cache.getHeight();
                            int width = cache.getWidth();
                            int bmSize = cache.getRowBytes() * height;

                           dst = ByteBuffer.allocate(bmSize);

                           bytesar = new byte[bmSize];


                            dst.position(0);
                            cache.copyPixelsToBuffer(dst);

                            dst.position(0);
                            dst.get(bytesar);

                           //I then write out the bytesar byte array AFTER I
write out the BMP header.


     The settings in the header are:

     private byte bitmapInfoHeader [] = new byte [40]; - Header size is 40
    private int biSize = BITMAPINFOHEADER_SIZE;
    private int biWidth = width                  //width of Bitmap
    private int biHeight = height               //height of Bitmap
    private int biPlanes = 1;
    private int biBitCount = 32;               //The bite count is 32
    private int biCompression = 0;

     size is computed by:
     int pad = (4 - ((width * 3) % 4)) * height;
     biSizeImage = ((width * height) * 3) + pad;

    private int biSizeImage
    private int biXPelsPerMeter = 0x0;
    private int biYPelsPerMeter = 0x0;
    private int biClrUsed = 0;
    private int biClrImportant = 0;

It's very close because here is what it looks like when I write out the .bmp
file.
As you can see it's upside down and the colors are off:
http://i1092.photobucket.com/albums/i409/ch39336688/test-2.jpg

In the same block of code I write out using the Android lib to make sure
that my image is good via the code:
FileOutputStream out = new FileOutputStream("test.png");
 cache.compress(Bitmap.
CompressFormat.PNG, 90, out);

And here is how that comes out (which is how I want):
http://i1092.photobucket.com/albums/i409/ch39336688/test.png

Again I don't just want to use compress to write out my images because I
have a lot of images and it kills my performance. So I want to stream the
images out to a .bmp file is what my overall goal is. Someplace in my .bmp
header I have something wrong I think.

Any help on what anyone thinks my issue is would be a great help. Thank you

-Chris

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to