Link to home
Start Free TrialLog in
Avatar of gkat
gkat

asked on

Saving a transparent PNG & GIF from EMF or BitBlt

I need to save a transparent PNG and GIF form another image.
The source image could be an EMF or, eventually, a bitmap composed using bitblt and masked it.
Avatar of dentab
dentab
Flag of United Kingdom of Great Britain and Northern Ireland image

Avatar of gkat
gkat

ASKER

Thanks a lot.
But actually I need to make a transparent file from an opaque bitmap. The process is:
- open a bitmap
- replace pixels from some rgb color to make a transparency
- save it as GIF or PNG

Other option is to make the GIF/PNG from EMF that is allready a transparent metafile.

I need to test the GFL SDK, may this will work...
so you need to apply a mask based on a given RGB value?

I have found this, but not checked it:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=49560&lngWId=1

Avatar of gkat

ASKER

As I see, it could be a solution. But my vb crashes when i run the sample.
By the way, there is class called cPallete, but i dont know how to use it...
I expect its for 256 colour (color) bitmaps.  They have a table to list the true RGB value for each pixel byte.  (I wrote my own bmp class beffore, but it couldnt deal with transparency or non BMPs).

I will take a look at the project from home later and see what I can do with it.
found a bug, have fixed.

Will post fix, instuctions and sample code shortly.
ASKER CERTIFIED SOLUTION
Avatar of dentab
dentab
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is the gif for use within a VB application, or for on the web?
Avatar of gkat

ASKER

Wow man!
The GIF is for multipropose uses. I am making an application that can exports images in many formats.

By the way, I can open the GIF in Photoshop but can not display it in IE7.

Do you know why?
no thats why I asked "Is the gif for use within a VB application, or for on the web?"

It not just for you, but I cannot see why.  It also works in FrontPage which is bizzare but it works in firefox also.  I an only imagine its some oddity in the standard.

Is this good enough?  If it were for use with IE I would have to search for a new answer as I cannot see why this code doesnt work for IE.
Avatar of gkat

ASKER

If the GIF can not be viewed in IE this algoritm will not 100% useful.
Using another library (as freeimage.dll) to re-save maybe this will work.

Off course I wll accept your solution anyway. Thanks a lot.

By the way, do you know how can i export an EMF into transparent GIF and PNG?
thanks for that!its put me at #12 for this year so far ;)

I don't but if I find anything on the subject, I'll post it as a comment