Re: BITMAP & grid
- From: "Severian [MVP]" <severian@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 16 Apr 2005 13:59:24 GMT
On Sat, 16 Apr 2005 13:19:47 +0900, "William"
<port@xxxxxxxxxxxxxxxxxx> wrote:
>Thanks Severian,
>
>I just tried. With Rectangle(), I can draw the gird but the interior of the
>rectangle also is painted.
>
>If I use FrameRect(), it doesn't work. The following is my source.
>
>void CMyView::OnDraw(CDC* pDC)
>{
> CBitmap bm;
> bm.LoadBitmap(IDB_BITMAP8); //8 pixcel * 8 pixcel as attached.
>
> // Create a pattern brush from the bitmap.
> CBrush cBrPattern;
> cBrPattern.CreatePatternBrush(&bm);
>
> // Select the brush into a device context, and draw.
> CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&cBrPattern);
> CPen* pOldPen;
> pOldPen = (CPen*)pDC->SelectStockObject(NULL_PEN);
>
> // pDC->Rectangle(CRect(50, 50, 200, 200));
> pDC->FrameRect(CRect(50, 50, 200, 200), &cBrPattern);
>
> //Restore the original brush.
> pDC->SelectObject(pOldBrush);
> pDC->SelectObject(pOldPen);
>}
>
>Please help
>William
>
>> LineDDA calls back to your code for every point on the line (and
>> you're calling SetPixel), which is making it slow.
>>
>> I would try FrameRect() with a patterned brush.
The pattern needs to fill the bitmap area like a checkerboard.
x0x0x0x0
0x0x0x0x
etc.
I would draw rectangles similarly to the way you are drawing the
lines: a bunch of tall, narrow ones followed by a bunch of wide, short
ones. For the outside border, like MSPoaint, follow with a full
rectangle around the entire area.
--
Phillip Crews aka Severian
Microsoft MVP, Windows SDK
Posting email address is real, but please post replies on the newsgroup.
.
- Follow-Ups:
- Re: BITMAP & grid
- From: William
- Re: BITMAP & grid
- References:
- BITMAP & grid
- From: William
- Re: BITMAP & grid
- From: Severian [MVP]
- Re: BITMAP & grid
- From: William
- BITMAP & grid
- Prev by Date: Re: GDI+ Image::GetPropertyItem What's the deal with PropertyTagExifShutterSpeed?
- Next by Date: Re: BITMAP & grid
- Previous by thread: Re: BITMAP & grid
- Next by thread: Re: BITMAP & grid
- Index(es):
Relevant Pages
|