Cut a bitmap under GDI+
-
I want to cut a bitmap and save the selection I cut what is anomalistic under GDI+.Is there any program that I can refer to? Thanks.
-
I want to cut a bitmap and save the selection I cut what is anomalistic under GDI+.Is there any program that I can refer to? Thanks.
Do you mean something like this?
// CropLeft, CropTop, CropWidth, CropHeight are INTs defining the portion of the source image
// to copy to the new destination imageGdiplus::Bitmap SrcBitmap(...);
...
Gdiplus::Bitmap DstBitmap(CropWidth, CropHeight, SrcBitmap.GetPixelFormat());
Graphics DstGraphics(&DstBitmap);
DstGraphics.DrawImage(&SrcBitmap, 0, 0, CropLeft, CropTop, CropWidth, CropHeight, UnitPixel);Mark
Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the number 3
-
Do you mean something like this?
// CropLeft, CropTop, CropWidth, CropHeight are INTs defining the portion of the source image
// to copy to the new destination imageGdiplus::Bitmap SrcBitmap(...);
...
Gdiplus::Bitmap DstBitmap(CropWidth, CropHeight, SrcBitmap.GetPixelFormat());
Graphics DstGraphics(&DstBitmap);
DstGraphics.DrawImage(&SrcBitmap, 0, 0, CropLeft, CropTop, CropWidth, CropHeight, UnitPixel);Mark
Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the number 3
I am not so familiar with GDI+,so I don't know that the code your provided can wheather achieve my purpose definitely.What I mean is the region in the bitmap is not necessarily a rect,it is mainly region that I draw with mouse.So it is a irregular region.Could you get it?;P
-
I am not so familiar with GDI+,so I don't know that the code your provided can wheather achieve my purpose definitely.What I mean is the region in the bitmap is not necessarily a rect,it is mainly region that I draw with mouse.So it is a irregular region.Could you get it?;P
Chen-XuNuo wrote:
What I mean is the region in the bitmap is not necessarily a rect,it is mainly region that I draw with mouse.
You could create a GraphicsPath object from the mouse points defining the outline and then use Graphics::SetClip() to set the clipping region to the GraphicsPath in the destination Graphics object before drawing the bitmap. Mark
Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the number 3