01-08-2013 11:09 PM
Aim of the application was to rotate the bit map image with the angle inputs given as 0-360 degrees(like transformation of an image). I tried with graph, and plot a polygon and i rotate it as per the given degree, but i couldn't able to do it in bitmap image, which we loaded.
Kindly provide, how i can read the bitmap and tilt it as per the degree i want.
01-09-2013 02:34 AM
Hello Harihara_Balaji,
first of all, your project does almost what is supposed to do, it simply needs some minor corrections: look at the modified code I am attaching.
The corrections I made are the following:
What is important to understand, is that the algorithm you are using rotates the polygon around the origin of axes (that is why I used bidirectional scales). To demonstrate is simply update "angle" variable by typing a new value or using up/down arrows and see the result on the second graph; I also added coordinates for a rectangle around the origin for you to see a different pattern result.
To rotate a polygon around its center you may for example calculate the center of the image, translate its coordinates so that it matches the origin, rotate and then move it back to original position.
Now, coming to your "real" question, rotation of an image is a bit more complicated, as it implies to deal with every pixel and with color depth. Additionally, when the angle is not a multiple of 90° you must consider aliasing, that is pixels that after rotation do not fall on the pixel grid (i.e. rotated coordinates are not integers). This implies some antialiasing algorithm to be used to correct those errors. Not a trivial task. Anyway, you can find some documentation on the web, for example on this page and this other one: these informations can give you a starting point for you to elaborate on.
01-09-2013 03:27 AM
Hi Roberto,
Thanks for your valuable reply, it's very helpfull for me, i will try to rotate the image based on the inputs you have provide. I will attach the files, after i accomplish my project. Thanks once again....
01-15-2013 05:51 AM
Dear Roberto,
I tried with the documents u provided, but still i feel difficulty to tilt an image, i can't able to read the pixels, i only can read the width and the height of the loaded image. Kindly provide few more solutions to tilt the image(bitmap) file with the angle as input.