Latest Uploads
image-21-0 ... -21-29.jpg

Jayenkai

image-15-0 ... -19-40.jpg

Jayenkai

image-15-0 ... -20-07.jpg

Jayenkai

Bumble Bee

dna

Tires

dna

Guess The Remake

rychan

Forum Home

Image rotation?

UserMessage
Posted : Tuesday, 30 November 2010, 10:57 | Permalink
spinal


I am trying to rotate an image (yes I know there is a rotate image function, I'm not going to use it). Anyway, the simple way is to do the following --

-->

However, it does leave gaps in the output image. I read somewhere that image rotation should be done backwards, as in, cycle through the output image and work out which pixel should be there, or something like that. But I have yet to find any info on how to do this.
Does anyone know how this is done?

-----
Download "Don't Flip Out!" Directly to your OUYA! (Click Here).
Homepage : http://spinalcode.co.uk
Posted : Wednesday, 01 December 2010, 02:46 | Permalink | Mark Here
Jayenkai


WW Entries : 103
It's quite awkward to think of this backwards, when you're working with pixels of a rotated rectangle.
Instead, simplify it.
You need to fill surrounding pixels of each pixel, so just do that.
Find each rx/ry, then go backwards for each pixel that's around it.

-->

-----
"Load, Next List!"
Homepage : http://AGameAWeek.com
Posted : Wednesday, 01 December 2010, 09:22 | Permalink | Mark Here
Andy_A


A quick and dirty way to fill in the gaps is to plot a 2x2 rect instead of a single pixel.

The drawback is that your image may be slightly distorted due to the way the rects overlap.

-->
Posted : Wednesday, 01 December 2010, 12:34 | Permalink | Mark Here
spinal


OK, I tweaked Jay's code a little, removed the initial rotation and instead worked completely backwards.

I assume though, that there is a simple way to find the min and max x and y values from checking the rotation of the image corners first though, I just guessed

-->

-----
Download "Don't Flip Out!" Directly to your OUYA! (Click Here).
Homepage : http://spinalcode.co.uk
Posted : Wednesday, 15 December 2010, 16:51 | Permalink | Mark Here
Teasy


That looks neat ^^

For finding the maximum image rotation corners,
I think you're looking for something like this, Spinal

-->

To see it in action,
in a slightly modified program:

-->

There is also room for more optimization ^^
Homepage : http://www.bettiesart.com/tc/contact
Posted : Saturday, 18 December 2010, 13:39 | Permalink | Mark Here
dna


Jay, In your code you use :

Graphics 1024,768,0,2
Graphics 320,240,0,3

What does that do? Why is that in there twice?

@Teasy: That's real smoothe. I can see where BB is slow when doing this.

Does BMax make a difference as far as the speed of the rot?


-----
DNA
Posted : Saturday, 18 December 2010, 15:06 | Permalink | Mark Here
Jayenkai


WW Entries : 103
,2 says "Make the window THIS big"
,3 says "Make this a scalable window."

With a scalable window, you can Maximise it if you wish, but everything ends up looking a bit blurry and stretchy.
It's a nice thing to have, but ,2 will always be clearer.

However..
,3 doesn't set the window's default size.
So, by setting a LARGE ,2 (and making the window be 1024x768) and THEN setting a smaller ,3, you end up with the 320x240 graphics being rescaled up to the 1024x768 size.

Basically, whereas we're drawing things to only a 320x240 area, they're actually being displayed 3 times bigger on the screen.

Otherwise, you'd be looking at a teensy tiny window!

-----
"Load, Next List!"
Homepage : http://AGameAWeek.com
Posted : Saturday, 18 December 2010, 16:03 | Permalink | Mark Here
CodersRule



I never knew you could do that.
I always wondered how to make a resizable window that big by default.
Homepage : http://tacosareawesome.com/
Posted : Saturday, 25 December 2010, 06:31 | Permalink | Mark Here
Teasy



dna:
if you optimize the code way more,
it should be smooth and superfast in blitz2d even

i still have some of blitzcoder's code laying around
from optimization/math wizards ^^
which does exactly that!

i am not familiar
with blitzmax' graphics interface/library
(opengl) benchmarks,
but i imagine that it usually depends
on (the wishes of) the coder
whether something is fast or not

taking into account that blitzmax
is more capable, flexible and faster in itself,
it may be fairly easy to get fast results in it

jayenkai:
that's a nice trick
i usually use some dll calls to pull that off ^^
( with userlibs it's a snap really )

codersrule:
particularly the functions from the user32.dll
can make the entire blitz window:
- stretch to overlap the entire screen,
- remove the caption and borders,
- and stay on top.
so basically a 'fake fullscreen'

here's the code i use to do that:
-->

and here's the "library" (interface) i'm using:
-->
WindowHandling.BB (25 Dec 2010)

Homepage : http://www.bettiesart.com/tc/contact
Posted : Monday, 17 January 2011, 09:36 | Permalink | Mark Here
Teasy


A few days ago I came across an old image rotation algorithm which is superfast by using 3 image skew operations.
I do not remember exactly who created the function, but I optimized it a little bit ^^

I do know that the creator was one of the brilliant minds over on BlitzCoder, which could be one of the following:
- Antony, Axeman1, BadJim, Bagels, BasicGamer2, Boomer, Chevron, CyberSeth, cR@wLy, DarkEagle, DJWoodgate, Eelco, Foppy, Gnasher, Gobble, LarsG, MutteringGoblin, ObviousDisaster, RepeatUntil, SirXriS, Skevo, World_Creator or someone else!

Anyway, here's the function with example program
I have inlined any required stuff from external files for your convenience ^^

-->
copyrectrotaskewopti 1e2.bb
Homepage : http://www.bettiesart.com/tc/contact
Latest Posts
Temporary Fix : iOS8 Image Uploading
Jayenkai Sun 06:44
NerdBlock
Jayenkai Sat 17:12
Movies : Pride
Jayenkai Sat 07:29
WaterFox
steve_ancell Sat 07:25
Batch Recolouring Images
rockford Sat 05:43
Static Molly
steve_ancell Fri 11:25
Microsoft : Where good coders go for a nap
Jayenkai Fri 05:21
Awful Site Design
Jayenkai Fri 01:44
AGameAWeek iOS Bundle
rychan Thu 08:46
Ex XBox
rychan Thu 07:54
More

Latest Items
Blog : Bedroom 2.0
Jayenkai Fri 06:01
Blog : 20 Years Ago....
steve_ancell Mon 15:28
Life : Back Online
Kuron Tue 11:48
Showcase : Munky Blocks DX
Jayenkai Mon 07:06
Showcase : Little Nemo's Nightmare
Jayenkai Sat 04:14
News : Newsletter #234
rychan Fri 08:02
Showcase : Space Rocket Adventurers
HoboBen Thu 16:56
Blog : Health Update : August 2014
Jayenkai Sat 11:31
Techy : Back from Game Dev Con!
Jayenkai Sun 16:52
Family : Sunday
Jayenkai Wed 03:31
Family : Good News (for once)
Kuron Tue 15:37
Showcase : Don't Tap The Zombies
therevillsgames Mon 16:26
Showcase : Mutant Monty
steve_ancell Wed 19:26
Techy : New Laptop!?
Kuron Fri 15:52
Showcase : Ascension 2 Live Wallpaper
CodersRule Fri 13:48
More

Who's Online
Kuron
Sun, at 07:58
spinal
Sun, at 07:52
steve_ancell
Sun, at 07:51
Jayenkai
Sun, at 07:38
rockford
Sun, at 07:27
9572AD
Sun, at 07:16
Dither
Sun, at 06:56
shroom_monk
Sun, at 03:35
Afr0
Sun, at 03:32
blanko1324
Sat, at 20:16
Link to this page
Site : Jayenkai 2006-Infinity | MudChat's origins, BBCode's former life, Image Scaler.