Sign in to follow this  
one mind

x=0, y=0 == TOP LEFT. How do u change it to bottom left

Recommended Posts

one mind    100
Hi, I am trying to learn software rasterization but i have already hit my first hurdle. I am using a picture box on a windows form with a bitmap on it to draw my lines. Basicaly, i am trying to draw a line by plotting pixels eg image.setpixel(x,y,color) This is working well but the problem is the y axis is in reverse and all my line slope are flipped and its getting cofusing. On windows forms, the image in the picbox pixels start at 0,0 in the top left. This is good for the x axis as i only need the first qudrant but i want the y axis to start at 0 in the bottom left. Is there a way to flip it? Sorry if i explained that to confusingly. Thanks :)

Share this post


Link to post
Share on other sites
Daaark    3553
Quote:
Original post by one mind
Hi, I am trying to learn software rasterization but i have already hit my first hurdle. I am using a picture box on a windows form with a bitmap on it to draw my lines. Basicaly, i am trying to draw a line by plotting pixels eg image.setpixel(x,y,color)
This is working well but the problem is the y axis is in reverse and all my line slope are flipped and its getting cofusing.
On windows forms, the image in the picbox pixels start at 0,0 in the top left. This is good for the x axis as i only need the first qudrant but i want the y axis to start at 0 in the bottom left.
Is there a way to flip it?
Sorry if i explained that to confusingly.
Thanks :)


A quick n' dirty hack would be to just use the height of the box... ie (x,height - y) Then the pixels would map how you wanted for now.

Share this post


Link to post
Share on other sites
one mind    100
Thanks guys, I was using a bitmap but i didnt see the Flip method :)
The only prob now is how to use it.
This is what i have done so far but it doesn't flip

Bitmap image = new Bitmap(width,height);
image.RotateFlip(RotateFlipType.RotateNoneFlipY);
display.Image = image;

image.SetPixel(5,5,Color.Black);

This still sets the pixel near the top left instead of bottom left.
Stange........
Is this the right way to use it?

Thanks again

Share this post


Link to post
Share on other sites
smart_idiot    1298
Quote:
Original post by Vampyre_Dark
A quick n' dirty hack would be to just use the height of the box... ie (x,height - y) Then the pixels would map how you wanted for now.


It should be (x,height - y - 1). With the later you end up with a range of 1 to height, we want a range of 0 to height - 1.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this