Page 1 of 1

Sprite To Image

Posted: Tue Apr 27, 2004 5:45 pm
by Johan_Haegg
Is there any way to convert a sprite to an image?
Trying to create an AVI on the fly with AVIServ, but when not using SaveSprite & LoadImage (slow) it wont work...
Tried ImageOutput() and some other things, but nothing works!
[EDIT]
I am trying to save what is seen onscreen and i use GrabSprite to get it, is there some other way thats better and allows me to get it as an image.

Posted: Tue Apr 27, 2004 10:16 pm
by BrendanE
I took this out of the forums recently... can't remember who's code it was but I have modified it slightly.... apologies to the original author.


;capture a piece of screen

Procedure.l CaptureScreenToImage(ImageNumber.l, Left.l, Top.l, Width.l, Height.l)
Protected BMPHandle.l

srcDC = CreateDC_("DISPLAY", "", "", 0)
trgDC = CreateCompatibleDC_(srcDC)
BMPHandle = CreateCompatibleBitmap_(srcDC, Width, Height)

SelectObject_( trgDC, BMPHandle)
BitBlt_( trgDC, 0, 0, Width, Height, srcDC, Left, Top, #SRCCOPY)

DeleteDC_( trgDC)
ReleaseDC_( BMPHandle, srcDC)

CreateImage(ImageNumber, Width, Height)
StartDrawing(ImageOutput())
DrawImage(BMPHandle, 0, 0)
StopDrawing()

DeleteObject_(BMPHandle)

EndProcedure

Posted: Wed Apr 28, 2004 10:55 am
by Johan_Haegg
Works like a charm and is faster than the not working method i used before. THANKS!

Posted: Wed Apr 28, 2004 9:07 pm
by BrendanE
You're welcome :)