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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. 2-d Graphics

2-d Graphics

Scheduled Pinned Locked Moved C / C++ / MFC
graphicshelpdelphiquestion
5 Posts 3 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.
  • C Offline
    C Offline
    Chambers
    wrote on last edited by
    #1

    Hi all, I am trying to make a custom drawing package in an MDI app. I have managed to load a bitmap into the child window using OnDraw and the CDC* pDC. I have also managed to get it to draw various lines to the screen when the users chooses the appropriate menu (yay :-D). However, these lines are drawn onto the CDC* pDC, is this the best way (I am getting flickering upon resizing of the child window)? or can you draw onto the CBitmap itself? The main focus of my problem is the fact I need to have low-level access to the pixel colours (in Delphi I was using scanline to scan whole lines of them into a PByteArray) so that I can change the ones that interest me, and leave the ones that don`t. Finally, what would be the best way to go about creating a layered approach, so that when I draw the lines etc. I don`t actually affect the underlying bitmap? would creating a new DC and drawing onto this, before outputting to the screen solve this? Anyway, I appreciate any help you could give on this guys, Thanks, Alan.:cool: AEGC

    R C 2 Replies Last reply
    0
    • C Chambers

      Hi all, I am trying to make a custom drawing package in an MDI app. I have managed to load a bitmap into the child window using OnDraw and the CDC* pDC. I have also managed to get it to draw various lines to the screen when the users chooses the appropriate menu (yay :-D). However, these lines are drawn onto the CDC* pDC, is this the best way (I am getting flickering upon resizing of the child window)? or can you draw onto the CBitmap itself? The main focus of my problem is the fact I need to have low-level access to the pixel colours (in Delphi I was using scanline to scan whole lines of them into a PByteArray) so that I can change the ones that interest me, and leave the ones that don`t. Finally, what would be the best way to go about creating a layered approach, so that when I draw the lines etc. I don`t actually affect the underlying bitmap? would creating a new DC and drawing onto this, before outputting to the screen solve this? Anyway, I appreciate any help you could give on this guys, Thanks, Alan.:cool: AEGC

      R Offline
      R Offline
      Remi Morin
      wrote on last edited by
      #2

      Hi, for the flickering problem you may use a memory device, a bitmap in memory that you attach to a CDC, then from thisd CDC you copy over the CDC* pDC. else you can, before drawing access to the "screen bitmap" and use it... but I've never do It. There are good tutorial in the Graphics section who may contain theses information Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com

      1 Reply Last reply
      0
      • C Chambers

        Hi all, I am trying to make a custom drawing package in an MDI app. I have managed to load a bitmap into the child window using OnDraw and the CDC* pDC. I have also managed to get it to draw various lines to the screen when the users chooses the appropriate menu (yay :-D). However, these lines are drawn onto the CDC* pDC, is this the best way (I am getting flickering upon resizing of the child window)? or can you draw onto the CBitmap itself? The main focus of my problem is the fact I need to have low-level access to the pixel colours (in Delphi I was using scanline to scan whole lines of them into a PByteArray) so that I can change the ones that interest me, and leave the ones that don`t. Finally, what would be the best way to go about creating a layered approach, so that when I draw the lines etc. I don`t actually affect the underlying bitmap? would creating a new DC and drawing onto this, before outputting to the screen solve this? Anyway, I appreciate any help you could give on this guys, Thanks, Alan.:cool: AEGC

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        Hi all, I am trying to make a custom drawing package in an MDI app. I've done the same thing and pretty much had to learn how to do it as I went. If you're using GDI ( i.e. not GDI+), buy Windows Graphics Programming by Feng Yuan. Hell, buy it anyway, I still refer to it . I have managed to load a bitmap into the child window using OnDraw and the CDC* pDC. First things first. Do NOT use CBitmap, it is a device dependant bitmap. In order to be able to edit and save differing bitmap bit depths instead of just ones the same depth as the screen res, use a DIBSection wrapper like the one Chris Maunder wrote which is in the bitmaps section on the site. I have also managed to get it to draw various lines to the screen when the users chooses the appropriate menu (yay ). However, these lines are drawn onto the CDC* pDC, is this the best way (I am getting flickering upon resizing of the child window)? or can you draw onto the CBitmap itself? The only way to draw onto a bitmap is through a CDC unless you're planning to access the bits directly. As has been said, you fix the flicker by drawing to a memory DC and then drawing direct to the screen in one blt. I also killed OnEraseBackground because I was drawing over the whole surface myself anyhow, and that goes a long way to killing flicker. The main focus of my problem is the fact I need to have low-level access to the pixel colours (in Delphi I was using scanline to scan whole lines of them into a PByteArray) so that I can change the ones that interest me, and leave the ones that don`t. Using a DIBSection solves this problem - you will have access to the underlying bits in order to do whatever you pretty much like. You'll figure this out quickly anyhow, but I'll mention that Windows stores colours in BGR format. Finally, what would be the best way to go about creating a layered approach, so that when I draw the lines etc. I don`t actually affect the underlying bitmap? would creating a new DC and drawing onto this, before outputting to the screen solve this? Anyway, I appreciate any help you could give on this guys, In that case you could store the lines drawn in a path and actually draw them to the screen DC instead of the one holding the original bitmap. I did something like this for the line/shape tools ( where you stretch out a shape and it doesn't become a permanent addition until you let go of the mouse ) -> when the mouse button was pressed I started drawing onto the memDC before blting it to the scr

        C 1 Reply Last reply
        0
        • C Christian Graus

          Hi all, I am trying to make a custom drawing package in an MDI app. I've done the same thing and pretty much had to learn how to do it as I went. If you're using GDI ( i.e. not GDI+), buy Windows Graphics Programming by Feng Yuan. Hell, buy it anyway, I still refer to it . I have managed to load a bitmap into the child window using OnDraw and the CDC* pDC. First things first. Do NOT use CBitmap, it is a device dependant bitmap. In order to be able to edit and save differing bitmap bit depths instead of just ones the same depth as the screen res, use a DIBSection wrapper like the one Chris Maunder wrote which is in the bitmaps section on the site. I have also managed to get it to draw various lines to the screen when the users chooses the appropriate menu (yay ). However, these lines are drawn onto the CDC* pDC, is this the best way (I am getting flickering upon resizing of the child window)? or can you draw onto the CBitmap itself? The only way to draw onto a bitmap is through a CDC unless you're planning to access the bits directly. As has been said, you fix the flicker by drawing to a memory DC and then drawing direct to the screen in one blt. I also killed OnEraseBackground because I was drawing over the whole surface myself anyhow, and that goes a long way to killing flicker. The main focus of my problem is the fact I need to have low-level access to the pixel colours (in Delphi I was using scanline to scan whole lines of them into a PByteArray) so that I can change the ones that interest me, and leave the ones that don`t. Using a DIBSection solves this problem - you will have access to the underlying bits in order to do whatever you pretty much like. You'll figure this out quickly anyhow, but I'll mention that Windows stores colours in BGR format. Finally, what would be the best way to go about creating a layered approach, so that when I draw the lines etc. I don`t actually affect the underlying bitmap? would creating a new DC and drawing onto this, before outputting to the screen solve this? Anyway, I appreciate any help you could give on this guys, In that case you could store the lines drawn in a path and actually draw them to the screen DC instead of the one holding the original bitmap. I did something like this for the line/shape tools ( where you stretch out a shape and it doesn't become a permanent addition until you let go of the mouse ) -> when the mouse button was pressed I started drawing onto the memDC before blting it to the scr

          C Offline
          C Offline
          Chambers
          wrote on last edited by
          #4

          Thanks for responses guys. I have used a memDC to draw on and then blt it to the screen CDC*, however, I still have flicker (only when resizing the window, I can move the child about and its fine), I think it may be something to do with OnEraseBackground do you think you can tell me how to kill it (do I just override it and then fail to do anything in the function call?). Many thanks again for the responses I got, they were superb.:-D Cheers, Alan;P AEGC

          C 1 Reply Last reply
          0
          • C Chambers

            Thanks for responses guys. I have used a memDC to draw on and then blt it to the screen CDC*, however, I still have flicker (only when resizing the window, I can move the child about and its fine), I think it may be something to do with OnEraseBackground do you think you can tell me how to kill it (do I just override it and then fail to do anything in the function call?). Many thanks again for the responses I got, they were superb.:-D Cheers, Alan;P AEGC

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            You should simply return TRUE to indicate that you've handled the message, don't do anything else or call the base method. Christian After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001

            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