[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 382
  • Last Modified:

gdiplus : how to mix images?

I have bitmap created like this:
pBitmap=new Bitmap(hBitmap,(HPALETTE)NULL);

How can I add small transparent image(cursor) to this bitmap ?

Thank you
0
serg111
Asked:
serg111
  • 6
  • 5
  • 3
2 Solutions
 
JohnGabyCommented:
You can create a Graphics object based in a Bitmap, and then paint another image into the bitmap:

http://msdn.microsoft.com/en-us/library/ms536159%28VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/ms535746%28VS.85%29.aspx
0
 
serg111Author Commented:
Ok , but which function to use to pain transparent image on top of bitmap?
0
 
JohnGabyCommented:
Is the source image transparent (e.g. a png image)?  If so, you just load the image and when you paint it, it will honor the transparency.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
serg111Author Commented:
I have transparent GIF image. What program I need to transform it to PNG? Microsoft Paint?

Also I recall that I've already been painting images with help of gdiplus::Graphics but old image was overwriten by new image. Or I am mistaken?

Thank you
0
 
JohnGabyCommented:
GDI+ will read  GIF files also.
0
 
serg111Author Commented:
Also I am not sure Paint will do in my case.
I want to modify Bitmap so I can save it later to file (I have code for saving Bitmap)
And Paint does paint to screen not to 2nd Bitmap?
0
 
JohnGabyCommented:
I am really not sure what you mean by "Paint'.  The function I suggested was 'DrawImage' (did you even look at the links I provided?).  In any case, the last time I tried to help you with GDI+ questions, you asked question after question, which I spent a great deal of time answering, only to have you later abandon the whole thread.  Frankly, I don't really think I can help you further.  Perhaps you need someone else who can explain things better than I can.
0
 
serg111Author Commented:
JohnGaby,

My current question is like this:
"How can I add small transparent image(cursor) to this bitmap ?"
Please check this question...

That is what I am asking about... output image to bitmap.
Not how to Paint image or DrawImage() ... ouput image to screen

Thank you
0
 
JohnGabyCommented:
I have ALREADY told you how to do that.  You create a Graphics object using the Bitmap object into which you want to paint.  Then you call the DrawImage method of that object and pass in the Bitmap object which contains your GIF file.  The result will be a Bitmap object which combines the two image.

0
 
serg111Author Commented:
>>The result will be a Bitmap object which combines the two image

Not sure what do you mean. DrawImage() accept one Bitmap object only... and does not return second Bitmap object...
Status DrawImage(          Image *image,
    const Point *destPoints,
    INT count
);

0
 
pgnatyukCommented:
1. Create new Bitmap object (new Bitmap with with, height and pixel format)
2. Create Graphics from this Bitmap (Graphics::FromImage)
3. Draw first image on it.
4. Draw second image on it.
On the image you create in 1., you have both images.

0
 
pgnatyukCommented:
http:#a26105022 was the answer.
It will be great if http:#a26117382 will be the assisted solution.

0
 
JohnGabyCommented:
I agree with pgnatyuk, we answered his question.  We cannot help it if he was unable to understand the answer.  I would be happy to split the points with pgnatyuk.
0
 
pgnatyukCommented:
Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now