123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|405|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> simple image warping ?

Tue, 17 Jun 2008, 02:50
spinal
I asked a couple of you guys in mud the other day, but none of us got anywhere, so maybe some others can help. Im trying to load an image by hand (on the ds) and plot it pixel by pixel onto the screen, but I want to warp it a little to look as if it's at an angle. But I cant figure out the maths behind it. I know some of you may suggest just using a 3d object or something, but im not going to do it that way, it must be done by pixeling the screen.

If you look at the following blitz code, it will load an image (to copy from, pretend its an array of pixels or even reading the bmp file directly) I want the first shape (the one being plotted) to look like the second one (the wire frame), but it needs to be done by hand, so setting the y pixel location depending on the x or something. Can anyone help?



-=-=-
Check out my excellent homepage!
Tue, 17 Jun 2008, 03:43
Jayenkai


Far from perfect, probably too slow, not smoothly scaled...

But does the job..

-=-=-
''Load, Next List!''
Tue, 17 Jun 2008, 04:23
Jayenkai
hehe, it's fun to play with



-=-=-
''Load, Next List!''
Tue, 17 Jun 2008, 07:40
mindstorm8191
I wrote this aspect-image routine which is probably something you're trying to do. It basically let me move 4 points of an image to anywhere I wanted. It was a tough algorithm to write. My first try was in Blitz which didn't go over too smoothly. I did it in C++ for an image library for Allegro and OpenGL. I honestly forget how I went about it, I haven't messed with it in a year or so. I believe I did a full pass on the target image-space, and from the source, I calculated where that would be for the aspect, and if that was in bounds on the image, collect the color values there. If not draw black or nothing.

Wish I could help you out some more. If you still need help, let me know and I can dig out my code, but it'll probably be a mess to dig through.

-=-=-
Vesuvius web game
Wed, 18 Jun 2008, 20:19
Orion Pax
That second one is sweet jay. I dragged all 4 corners around until it was upside down and backwards. That was fun.
Fri, 20 Jun 2008, 18:22
dna
You are good at what you do Jay.

If they posted samples like this at the purebasic site they would be something better.

-=-=-
DNA
Fri, 20 Jun 2008, 18:31
dna
I used this code



and put a 7x10 image into your program but there was some curved artifacts in the image when it drew it.
Where does this occur?


-=-=-
DNA
Sat, 21 Jun 2008, 04:10
Jayenkai
The line...


Isn't a perfect square, it's skewed, and warped...
Change it to a perfect square, and it comes out fine.

The warping occurs in that big squiggly maths stuff at the bottom.
Basically like so..


Nice and simple.. *cough*
Purely trial and error coding, there!

-=-=-
''Load, Next List!''
Sun, 22 Jun 2008, 11:46
Andy_A
Here's a version that fills in the "holes", but in doing so creates artifacts at certain angles.


Thu, 26 Jun 2008, 17:12
dna
That code does not work for me since I have B2d. The request file command I'll try to change.

-=-=-
DNA
Fri, 27 Jun 2008, 07:07
Andy_A
Yeah I wrote that using B+

You could just comment out that one line containing request file and it should compile without a hitch.