Page 1 of 1

More 2D drawing function

Posted: Sun Sep 05, 2010 8:01 pm
by Guimauve
Hello,

Some Image drawing operation are missing like flipping and rotating the drawing buffer.

Code: Select all

FlipDrawingBuffer(Direction); Direction : 0 = Horizontal, 1 = Vertical
RotateDrawingBuffer(Angle); Angle can be 90, 180 or 270
These functions will be a nice to have.

Best Regards
Guimauve

Re: More 2D drawing function

Posted: Sun Sep 05, 2010 8:13 pm
by luis
I know this is a feature request, but in the meantime if you want something like that there are many sources in the forum implementing something at least similar to what you asked (on images I mean, not sure if it's really what you want).

Just to let you know in case you missed them.

Re: More 2D drawing function

Posted: Sun Sep 05, 2010 8:59 pm
by Guimauve
The mirror function for the Window OS, unfortunately they don't work on Linux OS.

Code: Select all

Procedure MirrorImageX(Image) 
  ; Mirrors an image around the X-axis 
  Width  = ImageWidth(Image) 
  Height = ImageHeight(Image) 
  hDC = StartDrawing(ImageOutput(Image)) 
    StretchBlt_(hDC,0,Height,Width,-Height,hDC,0,0,Width,Height, #SRCCOPY) ; 
  StopDrawing() 
EndProcedure 
  
Procedure MirrorImageY(Image) 
  ; Mirrors an image around the Y-axis 
  Width  = ImageWidth(Image) 
  Height = ImageHeight(Image) 
  hDC = StartDrawing(ImageOutput(Image)) 
    StretchBlt_(hDC,Width,0,-Width,Height,hDC,0,0,Width,Height, #SRCCOPY) ; 
  StopDrawing() 
EndProcedure 
Why I need this :

1. I need to create 4 ButtonImageGadget(), so I would like to load the upward arrow then copy, rotate/flip the upward arrow for the 3 remaining direction.
(Workaround : Load 4 differents images)

2. Custom Texture loader for game project. The bmp image file seem to be saved upside down, so it's more easy to flip the texture than the texture UV mapping coordinate.
(Workaround : because my game project are in the early stage, I flip the UV map coordinate but it's not the best solution. It's possible to redraw the image point by point but it's slow, very slow.)

Best Regards
Guimauve

Re: More 2D drawing function

Posted: Sun Sep 05, 2010 9:04 pm
by Thorium
Guimauve wrote: 2. Custom Texture loader for game project. The bmp image file seem to be saved upside down, so it's more easy to flip the texture than the texture UV mapping coordinate.
(Workaround : because my game project are in the early stage, I flip the UV map coordinate but it's not the best solution. It's possible to redraw the image point by point but it's slow, very slow.)
Thats very easy to solve.
How do you load the bmp? Actualy you can flip it on loading by loading it line by line.

But the best solution is to save the file not flipped.

Re: More 2D drawing function

Posted: Sun Sep 05, 2010 9:11 pm
by luis
Guimauve wrote:The mirror function for the Window OS, unfortunately they don't work on Linux OS.
Maybe these can help ? Should be cross platform.

- RotateImage (nSrcImage, iDegRot) optimized for 90/180/270 degrees rotations

- FlipImage (nSrcImage) vertical flip

- MirrorImage (nSrcImage) horizontal flip (mirror)

http://www.purebasic.fr/english/viewtop ... 12&t=38975