Thread: Ask about SetPixel, Lineto and Moveto

  1. #1
    Registered User
    Join Date
    Jan 2002

    Smile Ask about SetPixel, Lineto and Moveto

    I write these below program to draw a rectangle which have black frame. In the rectangle have 4 red points and I draw the line between 2 point. So I get the result as this picture

    In the picture the red point is very small and the line between point is not exactly straight. I want the larger red point and straight line. Do you know how to do that?

    	// Paint white color as the background 
    	pDC->FillSolidRect(origin.x, origin.y, 2000, 2000, RGB(255,255,255));
    	int cx = 5;
    	int cy = 5;	
    	CPen pen, pen2;
    	pen.CreatePen(PS_SOLID,2, RGB(0,0,0));
    	pDC->Rectangle(cx,cy,(cx +256), (cy + 192));
    	pDC->SetPixel(45,10, RGB(255,0,0));
    	pDC->SetPixel(47,9, RGB(255,0,0));
    	pDC->SetPixel(79,45, RGB(255,0,0));
    	pDC->SetPixel(46,120, RGB(255,0,0));
    	pen2.CreatePen(PS_SOLID,1, RGB(0,0,255));

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    One pixel is one pixel, you can't change the size of it. What you could do is write a cluster of 3x3 pixels to simulate a bigger one.

    I don't know what you mean by "straight line" though. If you mean it is "pixelated" (the angle not being an even 45 degree), then there's not much you can do. There is a concept know as anti-aliasing which blurs the edges making it look smoother, but that is advanced (and nothing I know of).

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User
    Join Date
    Apr 2002
    You can try drawing some rects and filling them for larger "points". Or you can make your on function which will draw diamonds or what not. A pixel is a pixel, its pretty small. Also you can get rid of the aliasing with bi-linear filtering if you'd like but that's probably not within the scope of your project. However if you are interested you can find a lot of algorithms online.

Popular pages Recent additions subscribe to a feed