Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Invert grapics in 2D

Invert grapics in 2D

Scheduled Pinned Locked Moved C#
graphicshelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mikke_x
    wrote on last edited by
    #1

    Hi! I have made an application with a panel showing 2d graphics. Now I have found out that the grapichs are inverted, the x axis is pointing in the right direction but y is downwards when it should be upwards on the screen. I can´t really find any good way to invert the axis. I could just change code doing the drawing, but the panel is accessed from a lot of places and it would take a lot of time. What I would like to do is invert the axix at startup and that all the 2d graphics in the panel is drawn in the right way every time a graphics object is created via panel.CreateGraphics(). Help would be much appreciated! Regards! / Mikke

    H 1 Reply Last reply
    0
    • M Mikke_x

      Hi! I have made an application with a panel showing 2d graphics. Now I have found out that the grapichs are inverted, the x axis is pointing in the right direction but y is downwards when it should be upwards on the screen. I can´t really find any good way to invert the axis. I could just change code doing the drawing, but the panel is accessed from a lot of places and it would take a lot of time. What I would like to do is invert the axix at startup and that all the 2d graphics in the panel is drawn in the right way every time a graphics object is created via panel.CreateGraphics(). Help would be much appreciated! Regards! / Mikke

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      GDI and GDI+ all use an axis with the origin in the upper-left corner. This has always been the case. DirectX and I assume OpenGL (never worked with it) use the lower-left corner unless you transform the point of origin. The painting code will just have to be changed. You should encapsulate this in a derivative class of the Panel you should make, rather than doing the drawing outside the Panel that is responsible for showing the graphics. Encapsulation is a major feature of OOP.

      Microsoft MVP, Visual C# My Articles

      M 1 Reply Last reply
      0
      • H Heath Stewart

        GDI and GDI+ all use an axis with the origin in the upper-left corner. This has always been the case. DirectX and I assume OpenGL (never worked with it) use the lower-left corner unless you transform the point of origin. The painting code will just have to be changed. You should encapsulate this in a derivative class of the Panel you should make, rather than doing the drawing outside the Panel that is responsible for showing the graphics. Encapsulation is a major feature of OOP.

        Microsoft MVP, Visual C# My Articles

        M Offline
        M Offline
        Mikke_x
        wrote on last edited by
        #3

        ok, thank you! I thought it might be like that, but wanted to be sure. I have used a OOD doing the class hierachy and have encapsulated all the important features. Altough some of the functionallity has been placed outside the class because some of components in the application are drawing some graphics om the panel, mainly debug information. Looks like I will have to do some changes in the painting routines then.. / Mikke ( by the way, I think that openGL uses upper right corner too. If I remember correctly, I have not used it in a while.. )

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups