If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

However, the CopyImage method often fails and GetLastError returns 8 which means "not enough memory". What confuses me the most is that after this unsuccessful call I can happily create other bitmaps of the same size with the CreateCompatibleBitmap method. When there is not enough memory to copy a bitmap, shouldn't there be also not enough memory to create it? Or is there any other reason why CopyImage fails?

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?

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?

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 ?

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.