Sprite To Image

Advanced game related topics
Johan_Haegg
User
User
Posts: 60
Joined: Wed Apr 30, 2003 2:25 pm
Location: Västerås
Contact:

Sprite To Image

Post 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.
BrendanE
User
User
Posts: 63
Joined: Tue Nov 11, 2003 2:04 pm
Location: Derbyshire, England

Post 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
Johan_Haegg
User
User
Posts: 60
Joined: Wed Apr 30, 2003 2:25 pm
Location: Västerås
Contact:

Post by Johan_Haegg »

Works like a charm and is faster than the not working method i used before. THANKS!
BrendanE
User
User
Posts: 63
Joined: Tue Nov 11, 2003 2:04 pm
Location: Derbyshire, England

Post by BrendanE »

You're welcome :)
Post Reply