Re: BITMAP & grid

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.

Attachment:bitmap1.bmp
Description: Windows bitmap



Relevant Pages

  • Re: BITMAP & grid
    ... With Rectangle(), I can draw the gird but the interior of the ... > // Create a pattern brush from the bitmap. ... >> I would try FrameRect() with a patterned brush. ...
    (microsoft.public.win32.programmer.gdi)
  • Re: API Drawing, hatch, can I orient the hatch?
    ... I'm using a hatch to draw this rectangle. ... > Maybe what I'm looking for is the ability to draw create a custom hatch? ... In answer to your question though, yes you can create a pattern brush from any Bitmap so you could just draw your rotated hatch ...
    (microsoft.public.vb.general.discussion)
  • Re: API Drawing, hatch, can I orient the hatch?
    ... I'm using a hatch to draw this rectangle. ... > Maybe what I'm looking for is the ability to draw create a custom hatch? ... In answer to your question though, yes you can create a pattern brush from any Bitmap so you could just draw your rotated hatch ...
    (microsoft.public.vb.winapi.graphics)
  • Moving rectangle around StringGrid
    ... I am trying to move a rectangle around on a StringGrid. ... I can draw the ... rectangle using FrameRect, but I end up with many rectangles as I move it. ...
    (comp.lang.pascal.delphi.misc)
  • Re: BITMAP & grid
    ... I'd create a pattern brush with the correct pattern, ... FillRect to draw your lines as one pixel-wide rectangles. ... slow machines, ...
    (microsoft.public.vc.mfc)