Android Question How would you draw an arbitrary polygon FROM a sample image, as a square?

NekoOtome

New Member
I don't know how to put it into words very well, but imaging you want to copy from a sample texture to the screen
Instead of copying a square of the sample texture, you copy a polygon, I've connected the corners of how the output would be like
The reason is to fake a 2.5D effect the SNES/GBA are known for, particularly in racing games
Untitled.png
 

Brian Dean

Well-Known Member
Licensed User
Longtime User
That seems to be the other way around. From a square to a polygon.
It makes no difference. A square is a polygon. You are simply (!) transforming one polygon into another polygon. The geometrical algebra which translates one coordinate pair into another coordinate pair does not know what a square is.
 
Upvote 0

NekoOtome

New Member
OpenCV seems to be it

I recall libraries being 2 files, I've only been able to find an XML file. Have libraries in B4A been simplified since last I used it? Or do we have a way to download libraries from within B4A now?
 
Upvote 0

MasterGy

Member
Licensed User
Hi !

I quickly wrote a code module that draws a triangle from a 'bitmapcreator' texture into another 'bitmapcreator' object. You can draw a polygon with this, you just have to divide the polygon into triangles. It copies pixel by pixel, in principle it is fast, although I don't know what you want to use it for. It is good for drawing 2D triangles.

Sub DrawTriangle( _
BCsource As BitmapCreator,sx1 As Int,sy1 As Int, sx2 As Int,sy2 As Int, sx3 As Int,sy3 As Int, _
BCdest As BitmapCreator, dx1 As Int,dy1 As Int, dx2 As Int,dy2 As Int, dx3 As Int,dy3 As Int) As BitmapCreator

You specify a source, 3 coordinate points, a destination, and its 3 coordinate points.
It will draw the source onto the target and give you back a bitmapcreator, which is already the modified version.
 

Attachments

  • drawtriangle.zip
    147.7 KB · Views: 46
Last edited:
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
OpenCV seems to be it

I recall libraries being 2 files, I've only been able to find an XML file. Have libraries in B4A been simplified since last I used it? Or do we have a way to download libraries from within B4A now?
Please recheck the library link in the OpenCV thread.
Now it points to version 1.05 which is pretty much equal to 1.04 (by mistake I had removed the 1.04 .jar file from my Drive at some moment and it is no loger available).
 
Upvote 0
Top