Re: Loading image byte array

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks Frank, I actually got it working myself before I saw your code. I
load the my image like Michael Phillips suggested. Sure I'm currently
limited to BMP fileformat but that can be changed. Wouldnt your method mean
I would your method mean I would, for a moment, have two bitmaps at the
same time? If I use large images then this will eat memory for sure.

The one advantage with your method is that I will be able to use various
fileformats "out of the box" and don't need to make my own file format
parsers (BMP was easy, but I fear PNG; JPG and GIF can be a bit tricker).


"Frank Hileman" <frankhil@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> skrev i
meddelandet news:%23RIeYmlRHHA.4632@xxxxxxxxxxxxxxxxxxxxxxx
Load it first into a Bitmap as usual. You will know the width and height
at that point Then create a Graphics using a fast-access second bitmap (we
call it EffectBuffer), and render into that second bitmap using
DrawImageUnscaled. Dispose the first Bitmap.

Also I just posted some more information on the fast access technique in
the original thread.

Regards,
Frank Hileman

check out VG.net: http://www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio graphics editor

"Andreas" <dont.need@xxxxxxx> wrote in message
news:uS3VgSURHHA.4404@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

I recently found a thread where Frank Hileman suggested using the Bitmap
overload that enables you to get direct access to the image byte-array,
opposed to using unsafe code along with lockbits. I've written a small
wrapper for this functionality and its working ok. My question is, how
would I load an image from a file into this byte array? Obviously using
the Bitmap.FromFile() it out of the question since I dont want an extra
bitmap object in memory and besides it would require me to transfer pixel
by pixel over to the byte array.

So does anyone have any suggestions on how to do this, while (preferbly)
keep the ability to load various formats (I will settle for the onces
that Bitmap.FromFile can handle for now)? Speed is also a factor I would
like to increase as much as possible. It would require me to get the
image dimentions as well so I can initilize the correct byte array, get a
known stide size and so on.. you get the picture (no phun intended) =)


Thanks!

Andreas





.



Relevant Pages

  • Re: Skins - a great solution
    ... >> taking the top left bit as transparent you load it into a picture box ... C++ loops are obviously faster. ... would be to loop through the pixels in the array, directly, without calling ... I don't know how to get at the byte array from a bitmap handle. ...
    (microsoft.public.vb.winapi)
  • Loading image byte array
    ... I recently found a thread where Frank Hileman suggested using the Bitmap ... I load an image from a file into this byte array? ... object in memory and besides it would require me to transfer pixel by pixel ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Loading image byte array
    ... You must load and parse the headers yourself. ... The BITMAPFILEHEADER tells you that you have a valid bitmap and the actual ... location of the bitmap's byte array. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Loading image byte array
    ... You load your bitmap as a memory stream. ... What you have left is a packed DIB. ... bitmap's image byte array. ... I recently found a thread where Frank Hileman suggested using the Bitmap ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: VB3 is making my head spin!
    ... > and displaying it pixel by pixel] tell me how. ... compressed bitmap from an original 24 but full colour bitmap that is held on disk as a standard ... It shows you how to load a full colour 24bit .bmp file from disk and count ... Dim z As Long, t1 As Long, t2 As Long ...
    (comp.lang.basic.visual.misc)