Thank you again Kostya

I will research based on what you told me and let you know if I get it to
work.

-Chris

On Thu, Jan 6, 2011 at 2:12 PM, Kostya Vasilyev <kmans...@gmail.com> wrote:

>  Chris,
>
> First off, Windows bitmap are stored upside-down:
>
> http://en.wikipedia.org/wiki/BMP_file_format#Pixel_Array_.28bitmap_data.29
>
> The Pixel Array is a block of 32-bit DWORDs, that describes the image pixel
> by pixel. Normally pixels are stored "upside-down" with respect to normal
> image raster scan order, starting in the lower left corner, going from left
> to right, and then row by row from the bottom to the top of the image.[1]
>
>
> I *think* you can indicate top-down order by setting height to a negative
> value (in the file header).
>
> Secondly, the color problem - 32-bit per pixel Windows bitmaps use BGRx
> data format, blue-green-red, then one byte is ignored.
>
> Your input image is ARGB, so red and blue are switched around.
>
> Since you indicated that you'll be processing these images further, you
> could handle both issues in your server code. Or you could handle them on
> the phone, changing byte order around isn't going to be as time-consuming as
> compression.
>
> -- Kostya
>
> 06.01.2011 23:53, chris harper пишет:
>
> 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
>
>
>
> --
> Kostya Vasilyev -- WiFi Manager + pretty widget -- 
> http://kmansoft.wordpress.com
>
>  --
> 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<android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
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