locked
GDI+, bitmaps and graphics objects RRS feed

  • Question

  • Looking for some clarification with drawing on bitmaps in GDI+.  If I create a graphics object from a bitmap and then draw on that object, when I go to draw on the Bitmap again, will the previous draw be applied to it?  Or do I have to then take the graphics object and make a new bitmap from it?  The reason is that I am using a QuickFill method that needs a CBitmap object.  So I might use drawline from GDI+ and then convert the GDI+ bitmap to CBitmap to do a fill.  So are those lines I drew reflected in the bitmap automatically?

     

    Edit: Some code that may clarify

    Bitmap *gdiBitmap = new Bitmap(aBitmap);

    //Making graphics object from bitmap

    Graphics *g = Graphics::FromImage(gdiBitmap);

     g->DrawLine(myPen, (int)(pts[n1].x()+0.5), (int)(pts[n1].y()+0.5), (int)(pts[n2].x()+0.5), (int)(pts[n2].y()+0.5));

    //Now converting to CBitmap for quickfill

    CBitmap* newCBitmap = CBitmap::FromHandle(handle);

    int result;

    CQuickFill* CQuickFillObject = new CQuickFill();

    COLORREF fillClr, bordClr = RGB(0, 0, 0,);

    result = CQuickFillObject->QuickFill(newCBitmap, m_nImageSize.x() / 2, m_nImageSize.y() / 2, fillClr, bordClr);

     

    //Are both the drawline and quickfill now reflected in newCBitmap?

    • Edited by Adam54321 Wednesday, November 9, 2011 3:55 PM
    Wednesday, November 9, 2011 3:43 PM

Answers