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

Started by
5 comments, last by smart_idiot 19 years, 6 months ago
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 :)
Advertisement
Don't render directly to the picturebox. Use a bitmap object and flip that before assigning it to the picturebox.
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.

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
Not to worry
I was suppoeds to set the pixel befor flipping the bitmap.
It works now :)
Thanks
[edit]Ok, you got it [smile][/edit]
Pat.
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.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.

This topic is closed to new replies.

Advertisement