Set point's size
-
I want to ask could the point's size be set when I call SetPixel()?
-
I want to ask could the point's size be set when I call SetPixel()?
Do you want to set color of pixels on the screen with
SetPixel
WhiteSky
-
I want to ask could the point's size be set when I call SetPixel()?
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
-
I want to ask could the point's size be set when I call SetPixel()?
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.
-
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.
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
-
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
-
:-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...
: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
-
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.
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.
-
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.
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