• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 387
  • 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
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

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