Re: Loading and Saving a bitmap
From: Mike D Sutton (EDais_at_mvps.org)
Date: 04/06/04
- Next message: Björn Holmgren: "Multipost: microsoft.public.vb.general.discussion - was: API function GetFileTime"
- Previous message: joris: "API function GetFileTime"
- In reply to: tom: "Re: Loading and Saving a bitmap"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 6 Apr 2004 10:48:54 +0100
> Three notes about the posted code
> (let me know your positions) :
>
> Question:
>
> should be added this:
> Call DeleteObject(hSrcBMP)
<snip>
Generally the only reason the GetObject() would fail is that the Bitmap was not loaded successfully (i.e. hSrcBMP == 0), for a valid
Bitmap handle there's really no reason it should fail but yes it would be more complete to stick a DeleteObject() call in there just
in case.
> Question:
>
> could be an useful thing to use:
> Call GdiFlush
<snip>
You're not working in a multi-threadded environment so it would have no effect.
> Idea:
>
> in my opinion we can set the
> following value to 24,
> so to have
>
> With DIBHead ' Create new DIB header
> ...
> ...
> .biBitCount =24 ' BMInf.bmBitsPixel
> --
> End With
>
> and therefore load everything
It would force everything to load at 24-bit regardless of whether it needed it or not, which is a huge waste of resources for a
1-bpp image for example (24 times as much memory allocated!) Also 32-bit images would then loose their alpha channel data because
they're being fored down to a lower bit-depth. The benefit of DIB's is that you're not bound to a specific bit-depth (unlike DDB's)
but can work at the optimal depth rather than coorecing everything into a lowest/highest common denominator.
> (and obviously we don't need this more:
> 'If (BMInf.bmBitsPixel < 16) Then Exit Sub ' Paletted images not
> supported )
LoadImage() has problems loading the palette from a .BMP file under some OS' (search the MS Knowledgebase for more) so you may still
be bitten by that one and it's still very wasteful on resources for low bit-depth images. IMO it would be far better to write the
little extra bit of code to make it palette aware.
Hope this helps,
Mike
- Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: http://www.mvps.org/EDais/
- Next message: Björn Holmgren: "Multipost: microsoft.public.vb.general.discussion - was: API function GetFileTime"
- Previous message: joris: "API function GetFileTime"
- In reply to: tom: "Re: Loading and Saving a bitmap"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|