Re: Loading and Saving a bitmap

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

From: Mike D Sutton (EDais_at_mvps.org)
Date: 04/06/04


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/



Relevant Pages

  • Re: FMA - Episode 29
    ... Don Giovanni refusing the order to repent, ... >> the knowledge of the characters and the knowledge of the audience. ... Regardless of whether Ed recognizes the natural images ...
    (rec.arts.anime.misc)
  • Re: Filing systems and wikis
    ... display images. ... My approach was to create memberships for TNA, etc., so that they could look ... denigrating the image quality or by putting in a watermark. ...
    (soc.genealogy.britain)
  • Re: Somethings not right.??!!
    ... If you are going to do this, then you will be importing those images vs. ... leave the text a bit blurry and webbots will not be able to read and index. ... He originally was using a javascript menu with mouseover ...
    (microsoft.public.publisher.webdesign)
  • Re: Micol Advanced BASIC reclassification project
    ...  If you are using Sweet16 then you should send Eric Shepherd ... I haven't tried the images on my real IIgs yet, ... It strikes me as strange that no GS emulator will boot MAB ...
    (comp.sys.apple2)
  • Re: C as a scripting language
    ... from what I've seen a number of us do a fir bit of scripting. ... I have posted code here on a number of occasions. ... Flash Gordon ...
    (comp.lang.c)