Page 1 of 1
Resizing Sprites
Posted: Sun Nov 30, 2003 8:30 pm
by Paul
There is ResizeImage() for images and ZoomSprite3D() for 3D sprites...
It would really be nice to have a ResizeSprite() or ZoomSprite() command for sizing regular Sprites.
Posted: Mon Dec 01, 2003 11:20 am
by Psychophanta
Yes,
and RotateSprite() for 2D Sprites too.
Posted: Mon Apr 17, 2006 1:11 am
by va!n
really missing... dont only want have this for 3D Sprites!
please please add this command for the 2d commands too ^^ thx!
http://www.purebasic.fr/english/viewtop ... sizesprite
Posted: Mon Apr 17, 2006 4:18 am
by Hroudtwolf
Maybe this code could be an inspiration for Fred
Code: Select all
; 2005 Stefan (<-- brilliant DX-Progger sign. Hroudtwolf)
; PB-Club.de
; PB 4.00
#DDBLT_WAIT=16777216
Structure PB_Sprite
Sprite.l
Width.w
Height.w
Depth.w
Mode.w
FileName.l
RealWidth.w
RealHeight.w
ClipX.w
ClipY.w
EndStructure
Procedure ResizeSprite(Sprite,Width,Height);Gibt bei Fehlern 0 zurück.
If Width<=0 Or Height<=0:ProcedureReturn 0:EndIf
*Sprite.PB_Sprite=IsSprite(Sprite)
If *Sprite=0:ProcedureReturn 0:EndIf
*DDS.IDirectDrawSurface7=*Sprite\Sprite
If *DDS=0:ProcedureReturn 0:EndIf
*DDS\GetDDInterface(@*DD.IDirectDraw7)
If *DD=0:ProcedureReturn 0:EndIf
DDSD=AllocateMemory(124)
If DDSD=0:ProcedureReturn 0:EndIf
PokeL(DDSD,124)
If *DDS\GetSurfaceDesc(DDSD):FreeMemory(DDSD):ProcedureReturn 0:EndIf
PokeL(DDSD+8,Height)
PokeL(DDSD+12,Width)
If *DD\CreateSurface(DDSD,@*DDS2.IDirectDrawSurface7,0):FreeMemory(DDSD):ProcedureReturn 0:EndIf
rect.RECT
rect\left=0
rect\right=Width
rect\top=0
rect\bottom=Height
If *DDS2\Blt(rect,*DDS,0,#DDBLT_WAIT,0):FreeMemory(DDSD):*DDS\Release():ProcedureReturn 0:EndIf
FreeMemory(DDSD)
*DDS\Release()
*Sprite\Sprite=*DDS2
*Sprite\Width=Width
*Sprite\Height=Height
*Sprite\RealWidth=Width
*Sprite\RealHeight=Height
*Sprite\ClipX=0
*Sprite\ClipY=0
ProcedureReturn *DDS2
EndProcedure
;Test:
InitSprite()
InitKeyboard()
OpenScreen(800,600,16,"ResizeSprite()")
CreateSprite(1,128,128)
StartDrawing(SpriteOutput(1))
For M=0 To 500
Circle(Random(128),Random(128),10,Random($FFFFFF))
Next
DrawingFont(GetStockObject_(#ANSI_VAR_FONT))
DrawText(0,0,"Press enter to quit.",$FEFEFE,$000000)
StopDrawing()
DisplaySprite(1,0,0)
ResizeSprite(1,256,128)
DisplaySprite(1,128,0)
ResizeSprite(1,256,256)
DisplaySprite(1,384,0)
ResizeSprite(1,100,100)
DisplaySprite(1,640,0)
FlipBuffers()
Repeat
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Return)
Posted: Mon Apr 17, 2006 2:32 pm
by va!n
thanks! i will test it in a few minutes.. first i have to check server updated and talking live with some party guys... check out
www.secretly.de cool party releases! check out the "No Copy" video (german)

Posted: Mon Apr 17, 2006 8:17 pm
by va!n
@Hroudtwolf:
works fine here... but it would be great, if there is one more parameter... becuase i need to resize the image with doubling pixels and not with interpolation

an optional function would be nice
if you can post any example for resizing (also zooming like paint) it would be great! thanks!

Posted: Mon Apr 17, 2006 8:45 pm
by SoulReaper
@Hroudtwolf
Great example of how it should be done in Pure Basic using Direct x
Regards
Kevin

Posted: Mon Apr 17, 2006 9:46 pm
by Hroudtwolf
This source was writen by Stefan.
He is a great Guru of DX-Programming in PureBasic.
There are a lot of examples by him in the forums (german,english and pb-lounge)