The following seems to work okay, though there is probably a better way of doing this.
The problem with StartDrawing() StopDrawing() is that the hdc's are released automatically before we have time to pass them to the BitBlt function.
Try this.
Code: Select all
img0=UseImage(0)
img1=UseImage(1)
CreateImage(2, 200, 200)
hdc2=StartDrawing(ImageOutput())
hdc0 = CreateCompatibleDC_(hdc2)
hdc1 = CreateCompatibleDC_(hdc2)
SelectObject_(hdc0, img0)
SelectObject_(hdc1, img1)
BitBlt_(hdc2, 0,0, 200,200, hdc0, 0,0, #SRCCOPY)
BitBlt_(hdc2, 30,30, 140,140, hdc1, 0,0, #SRCCOPY)
StopDrawing()
DeleteDC_(hdc0)
DeleteDC_(hdc1)
I tested it with the following:
Code: Select all
img0=CreateImage(0, 200, 200)
img1=CreateImage(1, 200, 200)
UseImage(0) ;image 200x200 pixel stored in image #1
id=StartDrawing(ImageOutput())
Box(0,0,200,200,RGB(255,255,255)) ; White box.
StopDrawing()
UseImage(1) ;image 200x200 pixel stored in image #2
StartDrawing(ImageOutput())
Box(0,0,200,200,RGB(255,255,0)) ; Yellow box.
StopDrawing()
img0=UseImage(0)
img1=UseImage(1)
CreateImage(2, 200, 200)
hdc2=StartDrawing(ImageOutput())
hdc0 = CreateCompatibleDC_(hdc2)
hdc1 = CreateCompatibleDC_(hdc2)
SelectObject_(hdc0, img0)
SelectObject_(hdc1, img1)
BitBlt_(hdc2, 0,0, 200,200, hdc0, 0,0, #SRCCOPY)
BitBlt_(hdc2, 30,30, 140,140, hdc1, 0,0, #SRCCOPY)
StopDrawing()
DeleteDC_(hdc0)
DeleteDC_(hdc1)
UseJPEGImageEncoder()
SaveImage(0, "0.jpg",#PB_ImagePlugin_JPEG)
SaveImage(1, "1.jpg",#PB_ImagePlugin_JPEG)
SaveImage(2, "2.jpg",#PB_ImagePlugin_JPEG)
I may look like a mule, but I'm not a complete ass.