473,573 Members | 5,078 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

rotating an array....

Hi there...

i think it is a very common problem but i dont know why i didnt find
anything good for me on internet...

i want to simply rotate an array with 90,180,270 degrees....

here is how i allocated this....

srcimage = (LPBYTE)LocalAl loc(LMEM_FIXED, 320 * 200);

so any help or link?

Regards
Nov 14 '05 #1
4 5449
Roozbeh GHolizadeh <ro*******@yaho o.com> scribbled the following:
Hi there... i think it is a very common problem but i dont know why i didnt find
anything good for me on internet... i want to simply rotate an array with 90,180,270 degrees.... here is how i allocated this.... srcimage = (LPBYTE)LocalAl loc(LMEM_FIXED, 320 * 200); so any help or link?


Rotating it in place is going to be too hard for me to write off-hand,
but if you have a spare one, it's fairly easy.
Ditch all this system-specific rubbish (for the context of comp.lang.c
that is) first.

Rotate 180 degrees:
char *srcimage = malloc(320*200) ;
char *dstimage = malloc(320*200) ;
int i, j;
for (i=0; i<320; i++) {
for (j=0; j<200; j++) {
dstimage[i*200+j] = srcimage[(320-i)*200+200-j];
}
}

Rotating 90 or 270 degrees is going to lose information as your array is
not square. I'll make it square by chopping off a bit.

char *srcimage = malloc(200*200) ;
char *dstimage = malloc(200*200) ;
int i, j;
for (i=0; i<200; i++) {
for (j=0; j<200; j++) {
dstimage[i*200+j] = srcimage[j*200+i];
}
}

The rest is left as an exercise.

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"A friend of mine is into Voodoo Acupuncture. You don't have to go into her
office. You'll just be walking down the street and... ohh, that's much better!"
- Stephen Wright
Nov 14 '05 #2

On Tue, 4 May 2004, Roozbeh GHolizadeh wrote:

i think it is a very common problem but i dont know why i didnt find
anything good for me on internet...

i want to simply rotate an array with 90,180,270 degrees....

here is how i allocated this....

srcimage = (LPBYTE)LocalAl loc(LMEM_FIXED, 320 * 200);


You should try Google again. The first hit I got on
"rotate image array C source" was
http://www.worldserver.com/turk/open...teGWorld.c.txt
which is pretty ugly C code, but *says* it does what you want.

-Arthur

Nov 14 '05 #3
ro*******@yahoo .com (Roozbeh GHolizadeh) wrote:
i think it is a very common problem but i dont know why i didnt find
anything good for me on internet...

i want to simply rotate an array with 90,180,270 degrees....

here is how i allocated this....

srcimage = (LPBYTE)LocalAl loc(LMEM_FIXED, 320 * 200);

so any help or link?


comp.lang.c is the wrong newsgroup. They don't really do algorithms.
comp.graphics.a lgorithms is probably the right group. The basic
transformation for 90 degrees is just this:

for (y=0; y < YMAX; y++) for (x=0; x < XMAX; x++) {
dst[x][YMAX-1-y] = src[y][x];
}

But it assumes that you have allocated a dst array in a flipped
version of src. If you have a non-square array, and have some
flexibility about aspect ratios or sub-clip rectangles, then there are
more things you can and may desire to do in post processing of dst.

Anyhow, a more general rotation can be composed of 3 sheers, two
horizontal, and one vertical:

H * V * H^-1

Its just a question of solving for how much to sheer in the horizontal
and vertical directions. The point is that horizontal and vertical
sheers are fairly straight forward -- and can look really good if you
use bilinear filtering.

--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/
Nov 14 '05 #4
Thanks guys....

they worked perfect for me!!!

"Arthur J. O'Dwyer" <aj*@nospam.and rew.cmu.edu> wrote in message news:<Pi******* *************** ************@fi berglass.ww.and rew.cmu.edu>...
On Tue, 4 May 2004, Roozbeh GHolizadeh wrote:

i think it is a very common problem but i dont know why i didnt find
anything good for me on internet...

i want to simply rotate an array with 90,180,270 degrees....

here is how i allocated this....

srcimage = (LPBYTE)LocalAl loc(LMEM_FIXED, 320 * 200);


You should try Google again. The first hit I got on
"rotate image array C source" was
http://www.worldserver.com/turk/open...teGWorld.c.txt
which is pretty ugly C code, but *says* it does what you want.

-Arthur

Nov 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2393
by: Ian Hubling | last post by:
I'm trying to complete a rotating banner ad within a page I have. The rotating add has four images that rotate in three-second increments. I've got the images to rotate ok - but now I want to go one step further and can't figure out how to do it... I want to have it so that when the person clicks on the specific ad, they are taken to a URL...
1
2098
by: Grunt | last post by:
Hi, I have been trying to put together a rotating banner. the code works but I am having a problem with the caching of the banner images. no matter what I try the page is constantly reloading the images, even worse they are not loading completely. This version includes a (vain) attempt at forcing the banner images to cache. Apart form the...
31
6948
by: Royal Denning | last post by:
I am designing a table with 2 columns and 20 rows. I want to insert small images (each with a link) and a text title in each cell of the table. On refresh of the page, I would like to have the contents of each cell (picture/link and associated text) rotate randomly. Note that the text titles must remain with their associated picture and...
14
6537
by: mikeoley | last post by:
Why would this script below work on an html page: http://www.eg-designdev.com/aircylinders/test.htm But not a java page such as this: "http://www.eg-designdev.com/aircylinders/index3.jsp" Or does anybody have a simple slide show rotation script they could refer me to...thanks. <HTML><HEAD>
5
2533
by: Ricardo Furtado | last post by:
I'm trying, for a week or two, to create a procedure in order to rotate the image in any picturebox control in a cephalometry software. I've found a web site that shows how that can be done: http://vb-helper.com/index_vbnet.html but the problem is that the image doesn't stay at the top, instead, the image is created upon another bitmap, even...
3
5947
by: avalence | last post by:
Hello, I am trying to create a nice rotating earth globe (on mouse) on my web site, in order to display my professional relationships all over the world. The best way seems to be a javascript. In fact I still hesitate between java and javascript. My question is how can I create a interacting globe using a satellite photo. This is a very...
1
2558
by: AR123 | last post by:
Hi I want to set up a rotating banner. Not sure how to incorporate my rotating banner code into the code below. I want the rotating banner to be the main feature image? This is set up in mediasurface My code is: <!-- start page container --> <div id="pageContainer"> <!-- start middle content area --> <div id="genericMiddle">
6
3215
by: swethak | last post by:
Hi, I displayed the image taken from database.How to raotate that image using javascript.plz tell that how to start the logic.plz tell that some reference websites.
0
7792
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7709
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8039
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8218
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7800
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
3738
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3744
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2228
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1330
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.