Dumdidum
asked on
Get a rectangle from a bitmap and save to file
Hello
I want to select a part of a bitmap (for example rectangle from 40,40 to 100,100 and save this as new bitmap to a file...
Is this possible?
Thanks
Sven
I want to select a part of a bitmap (for example rectangle from 40,40 to 100,100 and save this as new bitmap to a file...
Is this possible?
Thanks
Sven
Well you could use BitBlt.... I'll see if there is a VB.NET equiv'
Const SRCCOPY As Integer = &HCC0020
Private Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal dwRop As Integer) As Integer
Dim BitmapSrc As New Bitmap("C:\X.bmp")
Dim BitmapSrcGraphic As Graphics
Dim BitmapSrcHDC As IntPtr
BitmapSrcGraphic = BitmapSrcGraphic.FromImage (BitmapSrc Obj)
Dim BitmapDest As New Bitmap(320, 240)
Dim BitmapDestGraphic As Graphics
Dim BitmapDestHDC As IntPtr
BitmapDestGraphic = BitmapDestGraphic.FromImag e(BitmapDe stObj)
Dim BltReturn As Integer
BltReturn = BitBlt(BitmapDestHDC.ToInt 32, 0, 0, 320, 240, BitmapSrcHDC.ToInt32, 5, 5, SRCCOPY)
=======
Non tested... let me know of problems
Private Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal dwRop As Integer) As Integer
Dim BitmapSrc As New Bitmap("C:\X.bmp")
Dim BitmapSrcGraphic As Graphics
Dim BitmapSrcHDC As IntPtr
BitmapSrcGraphic = BitmapSrcGraphic.FromImage
Dim BitmapDest As New Bitmap(320, 240)
Dim BitmapDestGraphic As Graphics
Dim BitmapDestHDC As IntPtr
BitmapDestGraphic = BitmapDestGraphic.FromImag
Dim BltReturn As Integer
BltReturn = BitBlt(BitmapDestHDC.ToInt
=======
Non tested... let me know of problems
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.