Hello there,
Your screen capture procedure has to be tweaked a bit if you want to capture an 8-bit screen and not lose the colors. Your typical screencapture proc begins with something like:
Code: Select all
SrcDC = CreateDC_("DISPLAY","","",dm.DEVMODE)
or similar, followed by CreateCompatibleBitmap_(SrcDC), all of which is fine for your native display colordepth but incompatible with an 8-bit screen. To correct this, exchange the first line for:
Code: Select all
SrcDC = StartDrawing(ScreenOutput())
and you should be golden, as long as a screen is already open when you call the procedure. Here's a sample proc:
Code: Select all
Procedure.l CaptureScreen(x, y, Width, Height)
srcDC = StartDrawing(ScreenOutput())
trgDC = CreateCompatibleDC_(srcDC)
BMPHandle = CreateCompatibleBitmap_(srcDC, Width, Height)
SelectObject_( trgDC, BMPHandle)
BitBlt_( trgDC, 0, 0, Width, Height, srcDC, x, y, #SRCCOPY)
StopDrawing()
DeleteDC_( trgDC)
ProcedureReturn BMPHandle
EndProcedure
and a test prog:
Code: Select all
Declare CaptureScreen(x, y, Width, Height)
InitSprite():InitKeyboard()
OpenScreen(800,600,8, "")
Repeat
ClearScreen($CC9999)
StartDrawing(ScreenOutput())
Circle(130,300,64,#White)
Circle(264,300,64,#Red)
Circle(400,300,64,#Green)
Circle(536,300,64,#Blue)
Circle(668,300,64,#Black)
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(300, 150, "Press Any Key to Continue...",#Yellow)
StopDrawing()
FlipBuffers()
ExamineKeyboard()
Until KeyboardReleased(#PB_Key_All)
hBmp = CaptureScreen(0,0,800,600)
CloseScreen()
GetObject_(hBmp, SizeOf(bitmap), bmp.BITMAP)
depth = bmp\bmBitsPixel
OpenWindow(0,0,0,800,600,"Captured Bitmap (depth = "+Str(depth)+" bits/pixel):",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
ImageGadget(0,0,0,0,0,hBmp)
Repeat:Until WaitWindowEvent()=#WM_CLOSE
Procedure.l CaptureScreen(x, y, Width, Height)
srcDC = StartDrawing(ScreenOutput())
trgDC = CreateCompatibleDC_(srcDC)
BMPHandle = CreateCompatibleBitmap_(srcDC, Width, Height)
SelectObject_( trgDC, BMPHandle)
BitBlt_( trgDC, 0, 0, Width, Height, srcDC, x, y, #SRCCOPY)
StopDrawing()
DeleteDC_( trgDC)
ProcedureReturn BMPHandle
EndProcedure