Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

I such at programming pls help (c++)

Name: Anonymous 2012-10-18 4:34

Hi.
I'm new at programming and I need some help with a task assigned for me.
I've been asked to Make a C++ program that can rotate an image q degrees around the point (x,y).

So far I have modified a program a friend of mine made that inputs the bitmap image and outputs a the new image, so that it works for what I want it to do.

I'm having trouble figuring out how to make the algorithm that rotates the image and how to code it. Another problem i'm having is that i'm quite new to programming, I can read and understand code but I have a really hard time just writing code.

Here's what I have made so far:
http://pastebin.com/VrxEYZMv
(The function rotate is the one i'm trying to make)

Name: Anonymous 2012-10-18 4:38

And by such I mean suck.

Name: ImageMagick 2012-10-18 4:40

convert -rotate [number] image.type final_image.type

Name: Anonymous 2012-10-18 4:45

Rotating a 2D picture is easy. For each point of the output, you compute the image of its coordinates through rotation by θ under translation by (-x, -y). Then, the value of that point is in the input at those transformed coordinates.

Name: Anonymous 2012-10-18 5:15

But right now the output image = the input image

Name: Anonymous 2012-10-18 5:49

>>4

and don't forget to blend the subpixel position results.

Name: Anonymous 2012-10-18 5:53

Okay, so i've now made these two variables.

long NewWidth = width * cos(radians) - height * sin(radians);

long NewHeight = height * sin(radians) + width * cos(radians);

But to rotate this using a rotation matrix i need to transform the pixel position by subtracting the rotation point.
But i don't really know hot to do this.

Name: Anonymous 2012-10-18 6:03

>>7

but you have it all there, just replace widht by x and height by y.

Name: Anonymous 2012-10-18 6:06

>>8
Hmm, tried putting this in as my output height and width, but the bitmap i got was corrupt

Name: Anonymous 2012-10-18 6:13

#define  char char

WHOA MAN

Name: Anonymous 2012-10-18 6:21

sepples a shit

Name: Anonymous 2012-10-18 7:19

>>9

why did you do that?

a meant the formula is the same for calculating the resulting position for each pixel. Also make sure the results are integers.

of course this formula needs to be updated with the rotation center (as previously proposed), as currently it is the top left corner of the image.

Name: Anonymous 2012-10-18 9:37

Read your linear algebra textbooks.

Don't change these.
Name: Email:
Entire Thread Thread List