Re: Loading image byte array



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: 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)
  • Re: Loading image byte array
    ... Thanks Frank, I actually got it working myself before I saw your code. ... load the my image like Michael Phillips suggested. ... at that point Then create a Graphics using a fast-access second bitmap (we ... by pixel over to the byte array. ...
    (microsoft.public.dotnet.framework.drawing)
  • Twain and Stream questions
    ... load it back from the file into my image control no problem. ... into/out of a stream. ... any ideas on how to load the bitmap directly ... internal static extern int GdipSaveImageToStream(IntPtr image, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: ImageList: Is this possible?
    ... Now I want to load ... There's an API fiunction that lets you create a bitmap in memory: ... lpInfoHeader As BITMAPINFOHEADER, ByVal dwUsage As Long, lpInitBits As ...
    (microsoft.public.vb.general.discussion)
  • Re: Large image
    ... The problem there is just trying to load a 3000x3000 bitmap is very likely ... to run the device out of memory long before it's fully in memory. ... templates and full source code then you can buy the SDF Extensions ...
    (microsoft.public.dotnet.framework.compactframework)