You are not logged in.

#1 2009-01-22 16:38:32

spiffen
Member

Draw part of image function

I was wondering if anyone have created a function that can take x, y, width, height of source image and x and y of the destination (screen) when drawing an image?

A function like this:
void GRRLIB_DrawImg(f32 xpos, f32 ypos, f32 source_xpos, f32 source_ypos, u16 width, u16 height, u8 data[], float degrees, float scaleX, f32 scaleY, u8 alpha);

Example: You have an image that is 10 x 10 pixels, and only want to draw an area of 2 x 2 pixels located at the bottom right part of the source image to coordinates 0,0 on the screen, then you call the function like this:

GRRLIB_DrawImg(0, 0, 8, 8, 2, 2, image, 0, 1, 1, 255);

Would be nice to have a function like that..

Offline

 

#2 2009-01-22 17:44:28

Crayon
Bad Mother Fucker

Re: Draw part of image function

Maybe the GRRLIB_DrawTile function would work for you check this page: http://grrlib.santo.fr/wiki/wikka.php?wakka=Day6

Offline

 

#3 2009-01-27 09:51:50

JustWoody
Member

Re: Draw part of image function

I did something similar for a flag waving effect for language selection in Mahjongg Wii, but I found that I has some corruption with parts of the image nearer the bottom. I figured out that I had to change the GGRLIB_DrawTile function slightly so that the tile number that you want to choose was a bigger variable type and this fixed it.

The original DrawTile function only supported one row of tiles, so I also changed it to support any amount of rows and columns (as long as the image does not go over 1024 for x or y pixels)

When I get home (if I remember smile ) I will post my version on here

The only other thing is that the tiles have to be multiples of 4 so your idea of 2x2 would not be possible

Last edited by JustWoody (2009-01-27 10:19:43)

Offline

 

#4 2009-01-27 16:52:37

NoNameNo
Administrator

Re: Draw part of image function

hi,

The svn version support 1024x1024 tileset.
no more glishes at the middle of the screen, and lot of more smile

Check it now !! and enjoy !! wink
http://code.google.com/p/grrlib/source/checkout

ps: the tiles do not have to be a multiple of 4, only the tileset does. wink

Offline

 

#5 2009-02-06 14:20:32

spiffen
Member

Re: Draw part of image function

Ohhhh, is it so. That is really good to know. Then I guess I could use the DrawTile function 'Crayon' mentioned earlier in this thread.

Perhaps I'll write a new function that is compatible with the "new" GRRLIB version, since I use the SVN version now..

NoNameNo wrote:

ps: the tiles do not have to be a multiple of 4, only the tileset does. wink

Offline

 

Board footer

Powered by FluxBB