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 / C++ / MFC
  4. Set point's size

Set point's size

Scheduled Pinned Locked Moved C / C++ / MFC
question
9 Posts 5 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
    Chen XuNuo
    wrote on last edited by
    #1

    I want to ask could the point's size be set when I call SetPixel()?

    H M B 3 Replies Last reply
    0
    • C Chen XuNuo

      I want to ask could the point's size be set when I call SetPixel()?

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      Do you want to set color of pixels on the screen with SetPixel


      WhiteSky


      1 Reply Last reply
      0
      • C Chen XuNuo

        I want to ask could the point's size be set when I call SetPixel()?

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        Chen-XuNuo wrote:

        could the point's size be set when I call SetPixel()?

        What point?

        "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

        1 Reply Last reply
        0
        • C Chen XuNuo

          I want to ask could the point's size be set when I call SetPixel()?

          B Offline
          B Offline
          bob16972
          wrote on last edited by
          #4

          Even though CDC::SetPixel takes a logical coordinate, it does not behave like the other drawing primitives in mapping modes (like MM_ISOTROPIC, MM_ANISOTROPIC, MM_HIMETRIC, etc...) in the sense of having a metrically translated "size". CDC::SetPixel will adapt it's coordinates correctly based upon the viewport and window extents (i.e. it's position will scale correctly relative to other drawing primitives like lines, rectangles, circles, and even text) but it will always remain a tiny little "dot" no matter how far you zoom in while the other drawing primitives and text grow. If you want a logical "dot" to scale, you will likely need to perform a MoveTo/LineTo with the appropriate start and end coordinates or maybe a filled rectangle with no border with the appropriate size or even some blit pattern all defined appropriately in the logical world. Then as you change the viewport and window extents, you will get the effect you are trying to achieve. However, use this method sparingly since drawing a "dot" to a device context is horribly expensive if your attempting to draw thousands, tens of thousands, or even millions of them as would be the case if your goal is to manipulate a bitmap or something to that effect. If this happens to be the context your in, consider getting the "bits" from a bitmap and working on those strictly in logical coordinates and later "blit" these to a device context to get the effects of the mapping mode metric translations. Look up MM_ANISOTROPIC and MM_ISOTROPIC in MSDN as these are the most versatile mapping modes available since they don't lock in the viewport and window extents like MM_HIMETRIC, MM_HIENGLISH, and all the rest do. I may be reading too much into what you asked but my gut reaction to any question regarding SetPixel/GetPixel is to assume the programmer is trying to manipulate bitmap bits as opposed to rendering drawing primitives. Either way, I hope my response helps somehow.

          J C 2 Replies Last reply
          0
          • B bob16972

            Even though CDC::SetPixel takes a logical coordinate, it does not behave like the other drawing primitives in mapping modes (like MM_ISOTROPIC, MM_ANISOTROPIC, MM_HIMETRIC, etc...) in the sense of having a metrically translated "size". CDC::SetPixel will adapt it's coordinates correctly based upon the viewport and window extents (i.e. it's position will scale correctly relative to other drawing primitives like lines, rectangles, circles, and even text) but it will always remain a tiny little "dot" no matter how far you zoom in while the other drawing primitives and text grow. If you want a logical "dot" to scale, you will likely need to perform a MoveTo/LineTo with the appropriate start and end coordinates or maybe a filled rectangle with no border with the appropriate size or even some blit pattern all defined appropriately in the logical world. Then as you change the viewport and window extents, you will get the effect you are trying to achieve. However, use this method sparingly since drawing a "dot" to a device context is horribly expensive if your attempting to draw thousands, tens of thousands, or even millions of them as would be the case if your goal is to manipulate a bitmap or something to that effect. If this happens to be the context your in, consider getting the "bits" from a bitmap and working on those strictly in logical coordinates and later "blit" these to a device context to get the effects of the mapping mode metric translations. Look up MM_ANISOTROPIC and MM_ISOTROPIC in MSDN as these are the most versatile mapping modes available since they don't lock in the viewport and window extents like MM_HIMETRIC, MM_HIENGLISH, and all the rest do. I may be reading too much into what you asked but my gut reaction to any question regarding SetPixel/GetPixel is to assume the programmer is trying to manipulate bitmap bits as opposed to rendering drawing primitives. Either way, I hope my response helps somehow.

            J Offline
            J Offline
            John R Shaw
            wrote on last edited by
            #5

            Wow – overkill. If they ask a question like that I doubt they would understand your answer. I understand the answer, but I really do not understand the question.

            INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

            B 1 Reply Last reply
            0
            • J John R Shaw

              Wow – overkill. If they ask a question like that I doubt they would understand your answer. I understand the answer, but I really do not understand the question.

              INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

              B Offline
              B Offline
              bob16972
              wrote on last edited by
              #6

              :-D I kinda realized that I was reading way too much into one sentence after I had it all typed out. But I figured why waste all that typing...

              J 1 Reply Last reply
              0
              • B bob16972

                :-D I kinda realized that I was reading way too much into one sentence after I had it all typed out. But I figured why waste all that typing...

                J Offline
                J Offline
                John R Shaw
                wrote on last edited by
                #7

                :laugh: I understand – I have trouble keeping my answers short too! But I am learning.

                INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

                1 Reply Last reply
                0
                • B bob16972

                  Even though CDC::SetPixel takes a logical coordinate, it does not behave like the other drawing primitives in mapping modes (like MM_ISOTROPIC, MM_ANISOTROPIC, MM_HIMETRIC, etc...) in the sense of having a metrically translated "size". CDC::SetPixel will adapt it's coordinates correctly based upon the viewport and window extents (i.e. it's position will scale correctly relative to other drawing primitives like lines, rectangles, circles, and even text) but it will always remain a tiny little "dot" no matter how far you zoom in while the other drawing primitives and text grow. If you want a logical "dot" to scale, you will likely need to perform a MoveTo/LineTo with the appropriate start and end coordinates or maybe a filled rectangle with no border with the appropriate size or even some blit pattern all defined appropriately in the logical world. Then as you change the viewport and window extents, you will get the effect you are trying to achieve. However, use this method sparingly since drawing a "dot" to a device context is horribly expensive if your attempting to draw thousands, tens of thousands, or even millions of them as would be the case if your goal is to manipulate a bitmap or something to that effect. If this happens to be the context your in, consider getting the "bits" from a bitmap and working on those strictly in logical coordinates and later "blit" these to a device context to get the effects of the mapping mode metric translations. Look up MM_ANISOTROPIC and MM_ISOTROPIC in MSDN as these are the most versatile mapping modes available since they don't lock in the viewport and window extents like MM_HIMETRIC, MM_HIENGLISH, and all the rest do. I may be reading too much into what you asked but my gut reaction to any question regarding SetPixel/GetPixel is to assume the programmer is trying to manipulate bitmap bits as opposed to rendering drawing primitives. Either way, I hope my response helps somehow.

                  C Offline
                  C Offline
                  Chen XuNuo
                  wrote on last edited by
                  #8

                  Haha~:),so many people don't understand my question.What I want to ask is that when I call the SetPixel function,a dot appear in where I click the mouse,and I want to change the size of the dot. In addition,I explain what function I want to perform.I open a bitmap which content is showing clothes in client area,and I want to get the border of the clothes through drawing manually.So I call the SetPixel in MouseMove to get each point I draw. If I use MoveTo/LineTo I can't get the each point I draw.I can only get the begin and the end point. I appreciate your suggestions.

                  M 1 Reply Last reply
                  0
                  • C Chen XuNuo

                    Haha~:),so many people don't understand my question.What I want to ask is that when I call the SetPixel function,a dot appear in where I click the mouse,and I want to change the size of the dot. In addition,I explain what function I want to perform.I open a bitmap which content is showing clothes in client area,and I want to get the border of the clothes through drawing manually.So I call the SetPixel in MouseMove to get each point I draw. If I use MoveTo/LineTo I can't get the each point I draw.I can only get the begin and the end point. I appreciate your suggestions.

                    M Offline
                    M Offline
                    Mark Salsbery
                    wrote on last edited by
                    #9

                    Chen-XuNuo wrote:

                    What I want to ask is that when I call the SetPixel function,a dot appear in where I click the mouse,and I want to change the size of the dot.

                    I had a feeling that's what you meant. You can't change the size of a screen pixel. The size of one pixel on the screen is detemined by the video resolution set for the monitor. All the pixels for a given resolution are the same size. That said, you can only go so small. For bigger "dots" you need to draw a cluster of pixels. An easy way to do this is in Windows GDI is to use a pen with a thickness the desired size. I'm not sure what's going wrong with your MoveTo/LineTo code. You'll need to post an example of how you set up the DC and make the calls so we can better help you. Mark

                    "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

                    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