Re: Why does CopyImage fail?
Don't know what the cause of your problem is, but why not use bitblt. I never even heard of CopyImage. Always used bitblt.
Re: Why does CopyImage fail?
Quote:
Originally Posted by
Skizmo
Don't know what the cause of your problem is, but why not use
bitblt. I never even heard of CopyImage. Always used bitblt.
I don't want to put the bitmap to a DC (to display it somewhere). I need to copy the bitmap data in the memory, so that I have two independent copies of it.
Re: Why does CopyImage fail?
I have always used BitBlt() too, but CopyImage() looks interesting.
It is said, at http://www.codeproject.com/Messages/...mage-woes.aspx , that the color depth must be the same for the source and target image. I am not sure that your last argument, LR_MONOCHROME, is correct. Can you try with something else? e.g. LR_CREATEDIBSECTION.
Re: Why does CopyImage fail?
This http://support.microsoft.com/kb/935607 could be an answer to your problem. Even if the description provided by MS would indicate otherwise since the color depth is just 1 bit.
Re: Why does CopyImage fail?
Quote:
Originally Posted by
olivthill2
I have always used BitBlt() too, but CopyImage() looks interesting.
It is said, at
http://www.codeproject.com/Messages/...mage-woes.aspx , that the color depth must be the same for the source and target image. I am not sure that your last argument, LR_MONOCHROME, is correct. Can you try with something else? e.g. LR_CREATEDIBSECTION.
I tried setting the flags to zero, with no effect. And now I'm even more confused - the program created and successfully copied 95 bitmaps. Then it created two more, the CopyImage method returned a non-NULL handle for them, but GetLastError called immediately after it returned 8! From then on, the program was able to create the bitmaps but CopyImage always returned NULL and GetLastError returned 8. What's going on? :confused:
Re: Why does CopyImage fail?
Quote:
Originally Posted by
OReubens
Thanks for an interesting link, but I am running Windows XP :(
Re: Why does CopyImage fail?
Another update: when I try using a DIB instead of a DDB (by calling CreateDIBSection instead of CreateCompatibleBitmap), CopyImage always passes but GetLastError after it returns always 8.
Re: Why does CopyImage fail?
Could be you're running into a limitation of GDI. And yes, even on XP there are still limits on certain GDI/USER/Kernel resources.
My guess is that you're hitting the limit of either bitmap handles, bitmap headers (which use memory in the global GDI space) combined with the fact that CopyImage needs a temporary buffer for the image rescaling (Even if you're not actually rescaling).
Why do you need an actual copy of the bitmap ? As far as windows is concerned, there's no real reason to actually ever have a duplicate. If you're not painting on it, why does it even matter ?