I was posting in another thread and something came up about the use of the CopyImage API function. Its been a long time since I wrote my original code which uses this function, so I don't remember why I chose to use the code I did, but in reexamining my code and the API docs I have some confusion of one of the flags used, LR_COPYRETURNORG
My code assumes I will get a totally new bitmap handle every time.
Rereading the API docs appears to indicate this flag will possibly return the original bitmaps handle when the size and resolution are the same (I assume resolution must be the current video resolution).
I wrote some test code to see if CopyImage indeed returns the original handle in this instance. To do this requires creating a DDB (device dependent bitmap) via the API, rather than loading an image.
Here is my test code:
Running the test on my system (WinXP Home, 32 bit color), CopyImage always appears to return a new bitmap handle and never the original one.
If the call were to return the original handle, it would break some of my code, so I need to know if (and if so, when) the CopyImage function will return the same handle as the original.
Are the API docs simply not clear on this (they are a bit cryptic) ?
Am I reading the API docs incorrectly ?
If some could test the test app on different systems (ie. Win 95,98,ME,2000, XP, Vista) and different video resolutions, it would be helpful.
I need to know whether CopyImage ever returns the same handle as the original bitmap, when using this flag (LR_COPYRETURNORG).
My code assumes I will get a totally new bitmap handle every time.
Rereading the API docs appears to indicate this flag will possibly return the original bitmaps handle when the size and resolution are the same (I assume resolution must be the current video resolution).
I wrote some test code to see if CopyImage indeed returns the original handle in this instance. To do this requires creating a DDB (device dependent bitmap) via the API, rather than loading an image.
Here is my test code:
Code:
#COMPILE EXE #INCLUDE "win32api.inc" 'TYPE BITMAP ' bmType AS LONG ' bmWidth AS LONG ' bmHeight AS LONG ' bmWidthBytes AS LONG ' bmPlanes AS WORD ' bmBitsPixel AS WORD ' bmBits AS BYTE PTR 'END TYPE FUNCTION PBMAIN LOCAL BM1 AS BITMAP, BM2 AS BITMAP LOCAL hDC AS LONG, hBmp1&, hBmp2&, T$ hDC = GetDC(%HWND_DESKTOP) hBmp1&=CreateCompatibleBitmap(hDC, 128,128) ReleaseDC %HWND_DESKTOP, hDC hBmp2&=CopyImage(hBmp1&, %IMAGE_BITMAP, 0,0,%LR_COPYRETURNORG) MSGBOX "Compare Handles: "+STR$(hBmp1&)+" "+STR$(hBmp2&) GetObject hBmp1&, SIZEOF(BM1), BM1 GetObject hBmp2&, SIZEOF(BM2), BM2 IF BM1<>BM2 THEN MSGBOX "format not the same" ELSE T$="Compare BITMAP structure values:"+CHR$(13)+CHR$(10) T$=T$+STR$(BM1.bmType)+" "+STR$(BM1.bmWidth)+" "+STR$(BM1.bmHeight)+" "+STR$(BM1.bmWidthBytes)+" "+STR$(BM1.bmPlanes)+" "+STR$(BM1.bmBitsPixel)+" "+STR$(BM1.bmBits)+CHR$(13)+CHR$(10) T$=T$+STR$(BM2.bmType)+" "+STR$(BM2.bmWidth)+" "+STR$(BM2.bmHeight)+" "+STR$(BM2.bmWidthBytes)+" "+STR$(BM2.bmPlanes)+" "+STR$(BM2.bmBitsPixel)+" "+STR$(BM2.bmBits) MSGBOX T$ END IF END FUNCTION
If the call were to return the original handle, it would break some of my code, so I need to know if (and if so, when) the CopyImage function will return the same handle as the original.
Are the API docs simply not clear on this (they are a bit cryptic) ?
Am I reading the API docs incorrectly ?
If some could test the test app on different systems (ie. Win 95,98,ME,2000, XP, Vista) and different video resolutions, it would be helpful.
I need to know whether CopyImage ever returns the same handle as the original bitmap, when using this flag (LR_COPYRETURNORG).
Comment