Page 1 of 1

How to copy a (clipped) sprite on an image ?

Posted: Mon Feb 09, 2004 12:28 pm
by pythagoras_156
Hello everyone,

My problem is the following :
I've got a sprite loaded. Basically, it's a tileset which i need to clip from to display a specific tile.
My problem is that i need to put that clipped part of the sprite tileset into an image (i'm working on a map editor and i can't display sprites in my listicon gadget).
So, the difficult part is to display the sprite on the image. I've tried a bit with bitblt_ function but i don't understand it fully, so i might be making a mistake somewhere.
Does anyone has an idea on how to copy a (clipped) sprite onto an image ?

Thanks in advance,

Pythagoras

Posted: Mon Feb 09, 2004 3:18 pm
by plouf
can't think a way to do that
but what you ask can be done diffrently with image commands :wink:
a) load the big image in a temporary image
b) grabimage ,grabimage grabs a square from another image and creates a new one :wink:

later if you wish to make sprites too you can use 2DDrawing command to
drawimage() in sprite -> startdrawing(spriteoutput())
:wink:

OOT are you greek ?

Posted: Mon Feb 09, 2004 4:22 pm
by LarsG
of course it can be done.. ;)
just load your tile image into a sprite, set drawing to another
image or sprite, and use this procedure to display the different tiles..
:wink:

Code: Select all

Procedure DrawClippedSprite(image, x, y, sizex, sizey, frame)
    Protected initwidth.l, initheight.l, yc.l
    initwidth = SpriteWidth(image)
    initheight = SpriteHeight(image)
    yc = Int(Round((frame * sizex) / initwidth,0))
    frame = frame - (yc * Int((initwidth / sizex)))
    yc = (yc * sizey)
    ; get the right part of the image
    ClipSprite(image,sizex * frame, yc, sizex, sizey)
    DisplayTransparentSprite(image,x,y)
    ; reset the clipsprite back to the initial values (size)
    ClipSprite(image,0,0,initwidth,initheight)
EndProcedure

Posted: Mon Feb 09, 2004 6:38 pm
by pythagoras_156
Thanks for your replies. I'll try the grabimage tip, looks like the best way to achieve it.

LarsG :
Your function is great and will turn out useful but what i was looking for was basically to copy a sprite onto an image. As far as I know, it's not possible to make a call for displaysprite and have it displayed onto an image (startdrawing(imageoutput()) ?)

plouf :
Nai, vre :D . Ypothetw k'esy ; Apo Athina ;

Posted: Mon Feb 09, 2004 7:36 pm
by plouf
i don;t understand how do you "draw" a sprite in an imageoutpu() ??

pythagoras take a visit in irc channel at night 10:00-11:00 greek time ;)