• Advertisement
Sign in to follow this  

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

This topic is 4876 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
Don't render directly to the picturebox. Use a bitmap object and flip that before assigning it to the picturebox.

Share this post


Link to post
Share on other sites
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
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
Not to worry
I was suppoeds to set the pixel befor flipping the bitmap.
It works now :)
Thanks

Share this post


Link to post
Share on other sites
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
Sign in to follow this  

  • Advertisement