c++ - How to Convert a gdi+ Bitmap-like struct into an HDC? -


How to change a bitmap-abstract structure in an HDC?

Now I have the image processing program in C ++, GDI.

If I have got HDC, I can attract whatever I want on HDC in GDI with the following code.

  // HDC is easy. HDC DC; Dc.DrawXXX // I can draw using the GDI method. Graphics GR (DC); // Now I can use the GDI method on DD  

My application is based on free image. I make fipImage. (Use Data Structures like Bitmap)

However, if I want to draw on the flywheel, now I have to copy the FifiIn Imagato bitmap, then click on the bitmap and finally the bitmap is reimagined

convert fipImage to bitmap -> draw on bitmap -> convert bitmap to fipWinImage

  fipWinImage imagefip; Bitmap * tempImg = new bitmap (imagefip-> GetWidth (), imagefip.GetHeigt (), pixel format 24bpprgb); // Memory Coming is Image's Large Graphics * PGR = Graphics :: Image (TempMG); HDC DC = PGR- & gt; GetHDC (); RECT RE; Rec.left = 0; Rec.top = 0; Rec.right = imagefip.GetWidth (); Rec.bottom = imagefip.GetHeight (); FipImage.draw (DC, REC); // Use StretchEdit () PGR-> Release HDC (DC); Graphics gr (tempImg); HDC DC = GR GATHDC (); // Get an HDC, use the GDI method GR Replace HDC (TempiCi); Draw using the // gr.drawXXX // gdi + method FipWinImage fipImg; // final result fipWinImage HBITMAP temporary; Color color; TempImg-> GetHBITMAP (color, & temp); FipImg-> CopyFromBitmap (temporary);  

I want to make an HDC directly from fipImage. And draw directly on fipWinImage How can I do this?

The first few explanations:

The reference to a device is basically a structure Which remembers things like foreground and background color, brush, font information and physical drawing surface (bitmap).

This is an easy thing to do when you are doing a graphics operation after someone else, then you have to specify all these things. You can pass all these settings more easily in this way. This is a DC that is really - a collection of just drawings, which includes attracting the surface.

One "HDC" is just a handle for one of these strokes. Due to being a "handle", it allows you to move the structure around the memory in order to manage the free space without your hints.

If you have access to the source code for the library, then you are using it FipWinImage :: Draw (...) method If they are using StretchDIBits, then copy them to your raw bitmap The data must be received at any point in a compatible format. It is also possible that the fipWinImage class is wrapping an underlying BITMAP or DIB etc.

The last step to getting your HDC ...

A bitmap can be selected in the "Selected" device reference, and only one DC at a time. If you can get internal HBITMAP from FIPIIMAg, you can select it in another DC (assuming it is still not selected in any other HC).

When you make a DC, the window automatically creates a 1x1 bitmap for it (since it is necessary to have a selected bitmap at all times in DC) when you select a new bitmap, then you have selected the first bitmap You are brought back to wait on it, because you will need to return it after doing it.

Hope that helps.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -