Ok, this is what I'm working on today. I'm not even sure where to start, but I'll be working on it while anyone interested considers this post.
Let's say I load a PNG (with alpha channel) into a GDI+ image. How would I get that hGdipImage into an EMF, all done in memory. Also, the EMF must contain the alpha channel.
Here's my objective: I'd like to put that EMF into a standard image control, having it show the form through the alpha layer. The EMF in an image control absolutely can be done, as shown by The Trick here.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
Hmmm, ok, I see code to create an EMF out of a regular bitmap image. However, I haven't figured out how to get a hGdipImage into a bitmap (and keep the alpha). It's fairly well documented that GdipCreateHBITMAPFromBitmap can't do this. Dil came up with another idea in another thread (using GdipCreateBitmapFromGdiDib), and I guess that's what I'm pursuing.
So now, figuring out how to get from hGdipImage to DIB.
Last edited by Elroy; Jun 25th, 2022 at 11:28 AM.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
Actually, GdipCreateBitmapFromGdiDib is going the wrong direction. Hmmm.
----------------
Ok, what I said above is wrong. GdipCreateHBITMAPFromBitmap doesn't delete the alpha. It's the other one (GdipCreateBitmapFromHBITMAP) that deletes the alpha. Ok, this gives me something to work with.
Last edited by Elroy; Jun 25th, 2022 at 11:28 AM.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
Ok, I've figured out that it's got to be an EMF+ file to have an alpha channel. Wheww, baby steps.
-----------
Some useful info:
EMF(old) and EMF+ files can encode transparency, but WMF files do not.
EMF+ can encode semitransparent colos, but EMF(old) cannot.
EMF+ format can display images more quickly than the EMF(old) format.
EMF+ is a newer format than EMF but both kinds of files use the same .EMF extension.
Last edited by Elroy; Jun 25th, 2022 at 12:05 PM.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
Well wqweto, you tell me. I've attached an EMF file. I'm not sure, but it seems to me that it's got to be an EMF+ file because it's got translucency (non-full-transparency) in it.
Just grab it and then directly load it into an Image control (Picture property in IDE, or LoadPicture during runtime, either way). You don't even have to run the project ... you'll see the translucency in design mode.
Am I missing something?
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
I have never worked with emf but from what I saw with GdipCreateMetafileFromEmf you can pass a gdi handle to gdi+
for file or stream reading it is not necessary to call emf's own ones, they work the same as with the other images
(GdipCreateMetafileFromFile and GdipCreateMetafileFromStream ) ----> GdipLoadImageFromFile and GdipLoadImageFromStream
Attachment 185184
the results are not very encouraging, maybe you have to investigate a little more, the image with gdi+ looks very pixelated
Ok, I've think I've got it. Vlad, it was one of your old posts (inspired by The Trick) that gave me the clues.
There was at least one bug in the code, but I found it and got it going.
I've just now got to clean it up and make it all into something reasonable.
I will post some examples once I get things a bit more cleaned up.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.