Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Convert a gdi+ Bitmap-like struct into an HDC?
    primarykey
    data
    text
    <p>How to Convert a Bitmap-like struct into an HDC?</p> <p>I am now writting image processing program in c++, gdi.</p> <p>If I got a HDC. I can draw whatever I like on the HDC in gdi by the following code.</p> <pre><code>// HDC is handy. HDC dc; dc.DrawXXX // I can draw using gdi method. Graphics gr(dc); // now I can also draw on the dc using gdi+ method. </code></pre> <p>My Application is based on FreeImage. I make of fipImage. ( use data struct like Bitmap )</p> <p>However if I want to draw on fipWinImage, now I have to copy fipWinImageto Bitmap, then draw on the Bitmap, and finally convert the bitmap into fipImage again, which is time comsuming and memory comsuming.</p> <p>Convert fipImage to Bitmap -> Draw on the bitmap -> convert bitmap to fipWinImage</p> <pre><code>fipWinImage imagefip; Bitmap* tempImg = new Bitmap(imagefip-&gt;GetWidth(), imagefip.GetHeigt(), PixelFormat24bppRGB); // memory comsuming is image is large Graphics *pGr = Graphics::FromImage(tempImg); HDC dc = pGr-&gt;GetHDC(); RECT rec; rec.left = 0; rec.top = 0; rec.right = imagefip.GetWidth(); rec.bottom = imagefip.GetHeight(); fipImage.draw(dc, rec); // using stretchdibits() pGr-&gt;ReleaseHDC(dc); Graphics gr(tempImg); HDC dc = gr.GetHDC(); // Get an Hdc, draw using gdi method gr.ReleaseHDC(tempDC); // gr.drawXXX // Draw using gdi+ method. fipWinImage fipImg; // final result fipWinImage. HBITMAP temp; Color color; tempImg-&gt;GetHBITMAP(color, &amp;temp); fipImg-&gt;copyFromBitmap(temp); </code></pre> <p>I want to construct a HDC directly from fipImage. and draw directly on fipWinImage How can I do this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload