Home > Software engineering >  Gdi delete some draw a straight line
Gdi delete some draw a straight line

Time:09-27

Want to achieve the function is to draw the multiple linear, randomly deleting one, because is not a pure color background, so can't use the background color to redraw, gdi + have the function of the exclusive or brush? For the win32 c + + programming environment

CodePudding user response:

GDI + if there is no such attribute method,
In idea, can draw a good background bitmap into memory, then directly map when necessary

CodePudding user response:

Draw a straight line before saving the background color (GetPixel)?

CodePudding user response:

Drawing a Line Filled with a Texture

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Home drawing a line or curve with a solid color, you can draw with a texture To the draw lines and curves with a texture, create a TextureBrush object, and pass the address of that TextureBrush object To Pen a constructor, the image associated with the texture brush is 2 tile the plane (invisibly), and when the Pen draws a line or curve, the stroke of the Pen uncovers certain pixels of the tiled texture.

The following example creates an Image object from The file Texture1. JPG. That Image is 2 construct a TextureBrush object, and The TextureBrush object is 2 construct a Pen object. The call to Graphics: : DrawImage draws The Image with its upper - left corner at (0, 0). The call to Graphics: : DrawEllipse USES The Pen object to draw a textured The ellipse.

Image Image (L "Texture1. JPG");
TextureBrush tBrush (& amp; Image);
Pen texturedPen (& amp; TBrush, 30);

Graphics. DrawImage (& amp; Image, 0, 0, the image. The GetWidth (), image, GetHeight ());
Graphics. DrawEllipse (& amp; TexturedPen, 100, 20, 200, 100);
The following does it shows The image and The textured The ellipse.







-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

CodePudding user response:

Remove effect, it is best to redraw all, or part of redrawing.
Instead of using the exclusive or pen.

CodePudding user response:

3/f tip is clear enough,

CodePudding user response:

Double buffer technique, the need to display some of the first drawing to the memory DC,
And then copy the memory DC to the window in the OPaint DC,

The above is my current in the use of methods,

CodePudding user response:

Can before drawing, will not need to draw the area (area) wipe out that reference code is as follows:
 void CEntityPen: : the Draw (HDC HDC, const Matrix * pMatrix) 
{
ASSERT (pMatrix!=NULL);

ASSERT (hDC!=NULL);

Graphics graph (hDC);
Graph. SetSmoothingMode (SmoothingModeAntiAlias);

Graph. SetTransform (pMatrix);

Pen Pen (m_crDrawPen m_nLineWidth);
Pen. SetLineCap (LineCapRound LineCapRound, DashCapRound);
Pen. SetLineJoin (LineJoinRound);

If (m_apEraseRegion [m_dwRegionIndex]!=NULL)
{
Graph. ExcludeClip (m_apEraseRegion [m_dwRegionIndex]);
}
Graph. DrawPath (& amp; Pen, m_pDrawPath);
}

CodePudding user response:

Saw, you this functionality, distinguish and the background and the line between the two layers,
And you are new, so feel the effect of the double buffer can satisfy you delete the line segment,

CodePudding user response:

 
Void CMyImageDlg: : TextBrush (pDC) CDC *
{
Image Image (L "water. JPG");
TextureBrush tBrush (& amp; Image);
Pen tPen (& amp; TBrush, 10);
Pen rPen (Color (0, 255255), 10);
Graphics g (pDC - & gt; GetSafeHdc ());
G.D rawImage (& amp; Image, 0, 0, the image. The GetWidth (), image, GetHeight ());
//1 seconds timer 1 change m_Erase
If (m_Erase)
{
G.D rawLine (& amp; TPen, 0, 0, the image. The GetWidth (), image, GetHeight ());
}
The else
{
G.D rawLine (& amp; RPen, 0, 0, the image. The GetWidth (), image, GetHeight ());
}
}

CodePudding user response:

  • Related