Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Two objects on a single Device Context

Sonx_hvn7Sonx_hvn7 Member Posts: 54
Is it possible to draw on a bitmap using a pen tool.. I would presume both BMP object and pen object would need to be on the same DC if that make sense...

Comments

  • AsmGuru62AsmGuru62 Member Posts: 6,519
    : Is it possible to draw on a bitmap using a pen tool.. I would
    : presume both BMP object and pen object would need to be on the same
    : DC if that make sense...
    :
    [color=Blue]Correct. Create a memory DC and select HBITMAP into it. Then select HPEN into DC and call drawing functions using a pen (lines, curves, polygons, etc.). Then select HBITMAP back (or draw it onto 'real' DC with BitBlt()) - it should have all these things drawn.[/color]
  • Sonx_hvn7Sonx_hvn7 Member Posts: 54
    : : Is it possible to draw on a bitmap using a pen tool.. I would
    : : presume both BMP object and pen object would need to be on the same
    : : DC if that make sense...
    : :
    : [color=Blue]Correct. Create a memory DC and select HBITMAP into it.
    : Then select HPEN into DC and call drawing functions using a pen
    : (lines, curves, polygons, etc.). Then select HBITMAP back (or draw
    : it onto 'real' DC with BitBlt()) - it should have all these things
    : drawn.[/color]

    this is my translation of your explanation

    [code]
    HPEN pen, oldPen;

    pen = CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
    hMemDC = CreateCompatibleDC(0);

    hOldBmp = SelectObject(hMemDC, hBmp);
    oldPen = (HPEN)SelectObject(hMemDC, pen);

    MoveToEx(hMemDC, centre.x,centre.y, NULL);
    LineTo(hMemDC, coord.x, coord.y);

    SelectObject(hMemDC, oldPen);
    SelectObject (hMemDC, hOldBmp);

    [color=Green]//DeleteObject(pen);[/color]
    DeleteDC(hMemDC);
    RadarBgrnd.Repaint ();
    [/code]
  • AsmGuru62AsmGuru62 Member Posts: 6,519
    : : : Is it possible to draw on a bitmap using a pen tool.. I would
    : : : presume both BMP object and pen object would need to be on the same
    : : : DC if that make sense...
    : : :
    : : [color=Blue]Correct. Create a memory DC and select HBITMAP into it.
    : : Then select HPEN into DC and call drawing functions using a pen
    : : (lines, curves, polygons, etc.). Then select HBITMAP back (or draw
    : : it onto 'real' DC with BitBlt()) - it should have all these things
    : : drawn.[/color]
    :
    : this is my translation of your explanation
    :
    : [code]:
    : HPEN pen, oldPen;
    :
    : pen = CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
    : hMemDC = CreateCompatibleDC(0);
    :
    : hOldBmp = SelectObject(hMemDC, hBmp);
    : oldPen = (HPEN)SelectObject(hMemDC, pen);
    :
    : MoveToEx(hMemDC, centre.x,centre.y, NULL);
    : LineTo(hMemDC, coord.x, coord.y);
    :
    : SelectObject(hMemDC, oldPen);
    : SelectObject (hMemDC, hOldBmp);
    :
    : [color=Green]//DeleteObject(pen);[/color]
    [color=Red]This ^^^ should not be commented out![/color]
    : DeleteDC(hMemDC);
    : RadarBgrnd.Repaint ();
    : [/code]:
    :
Sign In or Register to comment.