想要實作的功能是畫出多條直線后,可隨機洗掉某一條。因為不是純色背景,所以不能用背景色重繪。gdi+有異或畫筆的功能嗎?編程環境為win32 C++
uj5u.com熱心網友回復:
GDI+ 好像沒有這種屬性方法,換種思路,可以把繪制好的背景存成記憶體位圖,再需要時直接貼圖
uj5u.com熱心網友回復:
畫直線前 保存 背景色 (GetPixel)?uj5u.com熱心網友回復:
Drawing a Line Filled with a Texture--------------------------------------------------------------------------------
Instead of drawing a line or curve with a solid color, you can draw with a texture. To draw lines and curves with a texture, create a TextureBrush object, and pass the address of that TextureBrush object to a Pen constructor. The image associated with the texture brush is used to 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 used to construct a TextureBrush object, and the TextureBrush object is used to 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 ellipse.
Image image(L"Texture1.jpg");
TextureBrush tBrush(&image);
Pen texturedPen(&tBrush, 30);
graphics.DrawImage(&image, 0, 0, image.GetWidth(), image.GetHeight());
graphics.DrawEllipse(&texturedPen, 100, 20, 200, 100);
The following illustration shows the image and the textured ellipse.

--------------------------------------------------------------------------------
uj5u.com熱心網友回復:
洗掉的效果, 最好是全部重繪, 或者部分重繪.而不是使用異或筆來做.
uj5u.com熱心網友回復:
3樓提示得已經夠清楚了。uj5u.com熱心網友回復:
雙緩沖技術,把需要顯示的部分先繪制到記憶體DC中。然后再OPaint中把記憶體DC復制到視窗DC中。
以上是我目前在用的方法。
uj5u.com熱心網友回復:
可以在繪制之前,可以將不需要繪制的區域(擦除的區域)排除掉,參考代碼如下:void CEntityPen::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(&pen, m_pDrawPath);
}
uj5u.com熱心網友回復:
看了下。你這個功能,區分與背景與線段這兩個圖層。而且你還是新手,所以感覺雙緩沖的效果可以滿足你洗掉線段。
uj5u.com熱心網友回復:
void CMyImageDlg::TextBrush(CDC *pDC)
{
Image image(L"水珠.jpg");
TextureBrush tBrush(&image);
Pen tPen(&tBrush, 10);
Pen rPen(Color(255,255,0,0),10);
Graphics g(pDC->GetSafeHdc());
g.DrawImage(&image,0, 0, image.GetWidth(), image.GetHeight());
// 1 秒定時器 1改變 m_Erase
if(m_Erase)
{
g.DrawLine(&tPen, 0, 0, image.GetWidth(), image.GetHeight());
}
else
{
g.DrawLine(&rPen, 0, 0, image.GetWidth(), image.GetHeight());
}
}
uj5u.com熱心網友回復:
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/85606.html
標籤:界面
上一篇:獲取聲音片段流
