1. David: Win32Lib

David,

I've added support for 24-bit color depth bitmaps for use with createDIB.
(I skipped 16-bit because the structure was too confusing).  Let me know
if you'd like to take a look at the code (changes to 'createDIB' and
'packScanLine').

I'm writing an XPM viewer that uses my changes and it works fine on
images with more than 256 colors but it's a big memory hog (I'm sure I'm
missing some optimizations...).  My problem is, if I want to open a
different XPM file, I need to release the memory used by the previous DIB.
I tried Eu's 'free' (bad idea, crashed) and Win32Lib's 'deleteObject'
(didn't do anything for me).  What should I use to free the memory my DIB
handle is pointing at?

Thanx,
Brian

new topic     » topic index » view message » categorize

2. Re: David: Win32Lib

Brian Broker wrote:

> Let me know if you'd like to take a look at the
> code (changes to 'createDIB' and 'packScanLine').

Sure, I'm interested - especially since it's already coded.


> What should I use to free the memory my DIB
> handle is pointing at?

The DIB should be tracked as a resource; that's what:

   trackObject( -1, ForProgram, hDIB )

is supposed to do. The -1 is used because there is no parent for the object.
ForProgram indicates that the resource is supposed to last for the entire
program, as opposed to ForPaint, which is destroyed at the end of the next
onPaint event.

You should be able to destroy the DIB with:

   deleteObject( handle )

which ultimately calls the Win32 function DeleteObject to do the dirty work.

Did this answer the right question?

Just a note - XPM support is now native in the next release of Win32Lib, but
it shouldn't be too hard to integrate your code in. The main change was to
make the transparent color a global variable.

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu