Latest Uploads
image-14-1 ... 50-52.jpeg




They Are E ... where - GB


image-29-0 ... -20-30.jpg


God Of War 107999


Music. How ... do I even?


Forum Home

Image rotation?

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

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 :
Posted : Wednesday, 01 December 2010, 02:46 | Permalink | Mark Here

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 :
Posted : Wednesday, 01 December 2010, 09:22 | Permalink | Mark Here

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

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 :
Posted : Wednesday, 15 December 2010, 16:51 | Permalink | Mark Here

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 :
Posted : Saturday, 18 December 2010, 13:39 | Permalink | Mark Here

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?

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

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.

,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 :
Posted : Saturday, 18 December 2010, 16:03 | Permalink | Mark Here

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

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

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

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 :
Posted : Monday, 17 January 2011, 09:36 | Permalink | Mark Here

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 ^^

Homepage :
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Latest Posts
Join Us....
Jayenkai Sun 08:36
A+E stuff
steve_ancell Sun 08:33
Website Outages
rockford Sun 08:33
Mastertronic Makes Like.. Mastertronic!
Jayenkai Sun 03:31
Raspberry Pi Zero
Dabz Sun 01:45
AL Bums at Archive.Org
Jayenkai Sun 01:09
Centipede game progress.
steve_ancell Sat 17:01
FishFingers or FishCakes?
steve_ancell Fri 16:06
Black Friday 2015
Jayenkai Fri 12:14
BBC Three : Going Online
rychan Thu 13:54

Latest Items
Showcase : Beta Collexion
rychan Mon 13:55
Dev-Diary : Global Variables!
rychan Thu 06:33
Blog : Blippity Bleeep!
Jayenkai Fri 00:28
Showcase : Spike Dislike GB
rychan Wed 04:18
Blog : Back on the run
rychan Wed 01:03
Showcase : The Catcher Van
rychan Mon 04:40
Showcase : GodOfMiniWars
gameleaper Sun 20:12
Blog : Doctor Two
Jayenkai Tue 09:15
Showcase : WarTactical
gameleaper Mon 17:08
Showcase : Daily Dungeon
rychan Sun 05:33
Showcase : isometric prototype
Dabz Fri 12:43
Dev-Diary : Helichopper stuffs
Jayenkai Sat 18:10
Showcase : HexWarrior
gameleaper Thu 07:48
Showcase : SpikeDislike3
rychan Sun 13:51
Rant : Refresh Creations -> Refresh Games
rychan Sun 08:20

Who's Online
Sun, at 09:23
Sun, at 09:00
Sun, at 08:41
Sun, at 08:40
Sun, at 08:36
Sun, at 07:19
Sun, at 07:05
Sun, at 03:45
Sun, at 03:15
Sat, at 20:22
Link to this page
Site : Jayenkai 2006-Infinity | MudChat's origins, BBCode's former life, Image Scaler.