DrawImageArea etc...

BlitzMax Forums/BlitzMax Programming/DrawImageArea etc...

marksibly(Posted 2009) [#1]
Hi,

How do these sound for additions to max2d:

DrawSubImage image,x#,y#,sx#,sy#,sw#,sh#,frame=0
DrawSubImageRect image,x#,y#,w#,h#,sx#,sy#,sw#,sh#,frame=0

...where sx,sy,sw,sh are source image coords, so in total there's...

DrawImage
DrawImageRect
DrawSubImage
DrawSubImageRect

?


GfK(Posted 2009) [#2]
I think so. Will it take the current blend method into account, or just plop it on with a solidblend?

Hmmm... how about PasteImage and PasteImageRect?


Pete Rigz(Posted 2009) [#3]
They look like they may be useful. Would they be effectively converting the sx,sy etc., to uv coords under the hood?


marksibly(Posted 2009) [#4]
Hi,

> Would they be effectively converting the sx,sy etc., to uv coords under the hood?

Yes, they'd be official versions of the current DrawImageArea style routines floating around.


Dreamora(Posted 2009) [#5]
That would surely be a good additional to have it as integrated part without the requirement to get one of the floating around solutions.


dmaz(Posted 2009) [#6]
sounds great!


_Skully(Posted 2009) [#7]
Mark,

Thats definitely a great addition.. of course that means i'll have some changes to make lol


ImaginaryHuman(Posted 2009) [#8]
Looks good, would allow people to easily do things like particle systems on a single texture and spritesheets etc.

While you're at it how about applying an image to a polygon .... DrawImagePolygon?

And what about being able to adjust the individual vertices of the destination shape? With `rect` you have axis-aligned rectangles, but what about `Quad` versions which let you define 4 sets of 2 coordinates so that images can be easily warped?

Also how about defining per-vertex colors, and allowing drawing of smooth shaded non-textured polygons?

I think these would open lots of possibilities to many people.


N(Posted 2009) [#9]
Sounds fine to me.


Evil Roy Ferguson(Posted 2009) [#10]
I would like this.


Zeke(Posted 2009) [#11]

how about this function?? DrawImageStretch?


degac(Posted 2009) [#12]
I like it! Good!


Proger(Posted 2009) [#13]
DrawTexturedPoly(Image:TImage, xyuv#[], ...)  

This would be great!


_Skully(Posted 2009) [#14]
isnt DrawImageStretch the same thing as DrawSubImageRect?


Zeke(Posted 2009) [#15]
i dont know.. :D


slenkar(Posted 2009) [#16]
drawimagestretch is the ability to place vertices
Thats what I would like to see in Blitzmax


dynaman(Posted 2009) [#17]
I like it. It was one of the things I missed from Max. (drawsubimage that is)


BlitzSupport(Posted 2009) [#18]
The SubImage stuff would be a nice addition, but I've always wanted what Zeke's posted there as part of Blitz. (I'd like the texture to adjust so it's not split diagonally, though, ie. so it's interpolated correctly between all four corners.)


Jur(Posted 2009) [#19]
Any additions to max2d are welcome.


CyBeRGoth(Posted 2009) [#20]
I too would welcome what Zeke posted inbuilt too, with the addition that BlitzSuupport suggested and also the ability to have more than 4 vertices to work with, if we had 6, 8 etc we could do a lot of fancy things with it :)


slenkar(Posted 2009) [#21]
in my unofficial max2d module it works great in opengl (no splits or anything like that)


ImaginaryHuman(Posted 2009) [#22]
To be able to define an irregular quad where you can position each of the four corners separately to make the image warp, without a triangle split wrongly across the middle, you can instead define it as a `triangle fan`, centered at the averaged center position (which has to be recalculated each time you move the corners). You'd then have 4 separate triangles per image instead of 2, but it would look right.


_Skully(Posted 2009) [#23]
The SubImage stuff would be a nice addition, but I've always wanted what Zeke's posted there as part of Blitz. (I'd like the texture to adjust so it's not split diagonally, though, ie. so it's interpolated correctly between all four corners.)


Well, currently the Tquad in Max2D is private.. if that is made public it would be possible to adjust the coordinates of the vertices using:

Method SetCoords(tx0#,ty0#,tx1#,ty1#,tx2#,ty2#,tx3#,ty3#)

What is the purpose of setting areas private? ultimately it just prevents the more advanced users from tweaking Max2D unless they make their own modified version of Max2D


MGE(Posted 2009) [#24]
Add an optional "x,y" handle point to those routines and I'm in heaven. :) Would come in handy working with tiles, sprites, etc, etc. The default would be 0,0 (top left corner).


MGE(Posted 2009) [#25]
But please stablize any problems/pitfalls with the projection matrix first. ;)


_Skully(Posted 2009) [#26]
I don't think its possible actually.. no matter what, when you scale images containing single pixels / pixel width lines they will be impacted, particularly when moving.


Pete Rigz(Posted 2009) [#27]
Sounds cool. Not sure that they'd completely replace the single surface mods floating about as they at least store the UV coords in arrays for each frame so there's no extra calculations each time you draw the image. I don't imagine that would happen with these new commands as the sx/sy values would be designed to handle any values, but still welcome additions I'd say.


Brucey(Posted 2009) [#28]
there's no extra calculations each time you draw the image.

Well, you can say that about all of the default Max2D commands - they are designed to make things generic and easy to do, but not perhaps to do them as efficiently as you could if you coded something yourself for a specific task.
As you say, new features are always welcome, but at the same time, there's always plenty of room to roll your own :-)


_Skully(Posted 2009) [#29]
Exactly, however, with the current Max2D implementation restrictions we have to either duplicate the code or create a whole new branch to make those tweaks.


MGE(Posted 2009) [#30]
re: Proj matrix

The artifacting between lines due to tiles, etc, is not what I'm worrying about. I'm more concerned with proper aspect support going from a wide virtual to non wide physical and vice versa. Or is that already fixed?


QuickSilva(Posted 2009) [#31]
Sounds like a great addition to add. I`m looking forward to it.

Having official versions of these things is very handy as they are so easily missed in the forums which is a shame as there is some nice stuff out there.

Jason.


_Skully(Posted 2009) [#32]
MGE,

No I don't think letterboxing is built into that.. hmmm... I wonder how hard that would be to implement.


byo(Posted 2009) [#33]
I agree that any addition to Blitzmax is welcome as well.
Thank you for all your efforts, Mr. Sibly.
It's the work of a genius really.


Oddball(Posted 2009) [#34]
If you're taking requests for the Max2D module, I'd like to see a MOD2xBLEND mode. Should be easy enough to add, and would be really useful. :)


ImaginaryHuman(Posted 2009) [#35]
What would the modulate be used for in terms of `effects` in a game?


Oddball(Posted 2009) [#36]
ImaginaryHuman wrote:
What would the modulate be used for in terms of `effects` in a game?
I'd use it for some dynamic lighting/shadow effects, but I don't mind if you want to use it for some other effects instead.


Robert Cummings(Posted 2010) [#37]
Another raised hand for mod2x here... its usedful for lighting mostly, otherwise you end up with washed out graphics if you try to put both light and shadow on in separate passes.