Index: trunk/ab5.0/ablib/src/Classes/System/Drawing/Bitmap.ab
===================================================================
--- trunk/ab5.0/ablib/src/Classes/System/Drawing/Bitmap.ab	(revision 704)
+++ trunk/ab5.0/ablib/src/Classes/System/Drawing/Bitmap.ab	(revision 704)
@@ -0,0 +1,182 @@
+' Classes/System/Drawing/Bitmap.ab
+
+Namespace System
+Namespace Drawing
+
+Class Bitmap
+	Inherits Image
+Public
+	Sub Bitmap(native As *GpBitmap)
+		Image(native As *GpImage)
+	End Sub
+
+	Sub Bitmap(filename As String, useEmbeddedColorManagement = False As Boolean)
+		Image(CreateBitmapFromFile(ToWCStr(filename), useEmbeddedColorManagement) As *GpImage)
+	End Sub
+
+	Sub Bitmap(filename As PCWSTR, useEmbeddedColorManagement = False As Boolean)
+		Image(CreateBitmapFromFile(filename, useEmbeddedColorManagement) As *GpImage)
+	End Sub
+
+	Sub Bitmap(stream As IO.Stream, useEmbeddedColorManagement = False As Boolean)
+		Image(CreateBitmapFromABStream(stream, useEmbeddedColorManagement) As *GpImage)
+	End Sub
+
+	Sub Bitmap(stream As IStream, useEmbeddedColorManagement = False As Boolean)
+		Image(CreateBitmapFromStream(stream, useEmbeddedColorManagement) As *GpImage)
+	End Sub
+
+	Sub Bitmap(width As Long, height As Long, stride As Long, format As Imaging.PixelFormat, scan0 As *Byte)
+		Image(CreateBitmapFromScan0(width, height, stride, format, scan0) As *GpImage)
+	End Sub
+
+	Sub Bitmap(width As Long, height As Long, format /*= Imaging.PixelFormat.Format32bppARGB*/ As Imaging.PixelFormat)
+		Image(CreateBitmapFromScan0(width, height, 0, format, 0) As *GpImage)
+	End Sub
+
+	Sub Bitmap(width As Long, height As Long, target As Graphics)
+		Image(CreateBitmapFromGraphics(width, height, target) As *GpImage)
+	End Sub
+
+	Sub Bitmap(src As Image)
+/*
+		Image(CreateBitmapFromScan0(src.Width, src.Height, 0, src.PixelFormat, 0) As *GpImage)
+		Dim g = Graphics.FromImage(This)
+		g.DrawImage(src)
+		g.Dispose()
+*/
+		Throw New NotImplementedException
+	End Sub
+
+'	Sub Bitmap(src As Image, size As Size)
+'	Sub Bitmap(src As Image, width As Long, height As Long)
+Private
+	Static Function CreateBitmapFromFile(filename As PCWSTR, useEmbeddedColorManagement As Boolean) As *GpBitmap
+		If useEmbeddedColorManagement Then
+			SetStatus(GdipCreateBitmapFromFileICM(filename, CreateBitmapFromFile))
+		Else
+			SetStatus(GdipCreateBitmapFromFile(filename, CreateBitmapFromFile))
+		End If
+	End Function
+
+	Static Function CreateBitmapFromStream(stream As IStream, useEmbeddedColorManagement As Boolean) As *GpBitmap
+/*
+		If useEmbeddedColorManagement Then
+			SetStatus(GdipCreateBitmapFromStreamICM(stream, CreateBitmapFromStream))
+		Else
+			SetStatus(GdipCreateBitmapFromStream(stream, CreateBitmapFromStream))
+		End If
+*/
+		Throw New NotImplementedException
+	End Function
+
+	Static Function CreateBitmapFromABStream(stream As IO.Stream, useEmbeddedColorManagement As Boolean) As *GpBitmap
+'		Dim comStream = ComStreamFromABStream(stream)
+'		Try
+'			CreateBitmapFromABStream = CreateBitmapFromStream(comStream, useEmbeddedColorManagement)
+'		Finally
+'			comStream.Release()
+'		End Try
+		Throw New NotImplementedException
+	End Function
+
+	Static Function CreateBitmapFromScan0(width As Long, height As Long, stride As Long, format As Imaging.PixelFormat, scan0 As *Byte) As *GpBitmap
+		SetStatus(GdipCreateBitmapFromScan0(width, height, stride, format, scan0, CreateBitmapFromScan0))
+	End Function
+
+	Static Function CreateBitmapFromGraphics(width As Long, height As Long, target As Graphics) As *GpBitmap
+		SetStatus(GdipCreateBitmapFromGraphics(width, height, target.NativeGraphics, CreateBitmapFromGraphics))
+	End Function
+
+Public
+	Function Clone(ByRef rc As Rectangle, format As Imaging.PixelFormat) As Bitmap
+		Dim cloned As *GpBitmap
+		SetStatus(GdipCloneBitmapAreaI(rc.X, rc.Y, rc.Width, rc.Height, format, NativeBitmap, cloned))
+		Try
+			Clone = New Bitmap(cloned)
+		Catch e As Exception
+			GdipDisposeImage(cloned)
+			Throw e
+		End Try
+	End Function
+
+	Function Clone(ByRef rc As RectangleF, format As Imaging.PixelFormat) As Bitmap
+		Dim cloned As *GpBitmap
+		SetStatus(GdipCloneBitmapArea(rc.X, rc.Y, rc.Width, rc.Height, format, NativeBitmap, cloned))
+		Try
+			Clone = New Bitmap(cloned)
+		Catch e As Exception
+			GdipDisposeImage(cloned)
+			Throw e
+		End Try
+	End Function
+
+	Function LockBits(ByRef rc As Rectangle, flags As DWord, format As Imaging.PixelFormat) As Imaging.BitmapData
+		SetStatus(GdipBitmapLockBits(NativeBitmap, rc, flags, format, LockBits))
+	End Function
+
+	Sub UnlockBits(ByRef lockedBitmapData As Imaging.BitmapData)
+		SetStatus(GdipBitmapUnlockBits(NativeBitmap, lockedBitmapData))
+	End Sub
+
+	Function GetPixel(x As Long, y As Long) As Color
+		SetStatus(GdipBitmapGetPixel(NativeBitmap, x, y, GetPixel))
+	End Function
+
+	Sub SetPixel(x As Long, y As Long, color As Color)
+		SetStatus(GdipBitmapSetPixel(NativeBitmap, x, y, color))
+	End Sub
+
+	Sub SetResolution(xDpi As Single, yDpi As Single)
+		SetStatus(GdipBitmapSetResolution(NativeBitmap, xDpi, yDpi))
+	End Sub
+
+	Static Function FromDirectDrawSurface7(surface As VoidPtr) As Bitmap
+		Dim native As *GpBitmap
+		GdipCreateBitmapFromDirectDrawSurface(surface, native)
+		FromDirectDrawSurface7 = New Bitmap(native)
+	End Function
+
+	Static Function FromBITMAPINFO(ByRef bi As BITMAPINFO, data As VoidPtr) As Bitmap
+		Dim native As *GpBitmap
+		GdipCreateBitmapFromGdiDib(bi, data, native)
+		FromBITMAPINFO = New Bitmap(native)
+	End Function
+
+	Static Function FromHBITMAP(hbm As HBITMAP, hpal As HPALETTE) As Bitmap
+		Dim native As *GpBitmap
+		GdipCreateBitmapFromHBITMAP(hbm, hpal, native)
+		FromHBITMAP = New Bitmap(native)
+	End Function
+
+	Static Function FromHICON(hicon As HICON) As Bitmap
+		Dim native As *GpBitmap
+		SetStatus(GdipCreateBitmapFromHICON(hicon, native))
+		FromHICON = New Bitmap(native)
+	End Function
+
+	Static Function FromResource(hInstance As HINSTANCE, bitmapName As PCWSTR) As Bitmap
+		Dim native As *GpBitmap
+		SetStatus(GdipCreateBitmapFromResource(hInstance, bitmapName, native))
+		FromResource = New Bitmap(native)
+	End Function
+
+	Static Function FromResource(hInstance As HINSTANCE, bitmapName As String) As Bitmap
+		FromResource = FromResource(hInstance, ToWCStr(bitmapName))
+	End Function
+
+	Function GetHBITMAP(colorBackground = &hff000000 As Color) As HBITMAP
+		SetStatus(GdipCreateHBITMAPFromBitmap(NativeBitmap, GetHBITMAP, colorBackground))
+	End Function
+
+	Function GetHICON() As HICON
+		SetStatus(GdipCreateHICONFromBitmap(NativeBitmap, GetHICON))
+	End Function
+Private
+	Function NativeBitmap() As *GpBitmap
+		NativeBitmap = This.NativeImage As *GpBitmap
+	End Function
+End Class
+
+End Namespace
+End Namespace
Index: trunk/ab5.0/ablib/src/Classes/System/Drawing/Image.ab
===================================================================
--- trunk/ab5.0/ablib/src/Classes/System/Drawing/Image.ab	(revision 703)
+++ trunk/ab5.0/ablib/src/Classes/System/Drawing/Image.ab	(revision 704)
@@ -14,4 +14,8 @@
 	Function NativeImage() As *GpImage
 		NativeImage = nativeImage
+	End Function
+
+	Static Function FromFile(filename As String, useEmbeddedColorManagement = False As Boolean) As Image
+		FromFile = FromFile(ToWCStr(filename), useEmbeddedColorManagement)
 	End Function
 
@@ -49,6 +53,6 @@
 		SetStatus(GdipGetImageType(nativeImage, imageType))
 		Select Case imageType
-'			Case ImageTypeBitmap
-'				FromNativeImage = New Bitmap(native)
+			Case ImageTypeBitmap
+				FromNativeImage = New Bitmap(native)
 '			Case ImageTypeMetafile
 '				FromNativeImage = New Metafile(native)
@@ -75,4 +79,8 @@
 	End Function
 
+	Sub Save(filename As String, format As Imaging.ImageFormat)
+		SaveImpl(ToWCStr(filename), format.Guid)
+	End Sub
+
 	Sub Save(filename As PCWSTR, format As Imaging.ImageFormat)
 		SaveImpl(filename, format.Guid)
@@ -87,4 +95,8 @@
 	End Sub
 */
+	Sub Save(filename As String, encoder As Imaging.ImageCodecInfo, encoderParams As Imaging.EncoderParameters)
+		SaveImpl(ToWCStr(filename), encoder.Clsid, ToNativeEncoderParameters(encoderParams))
+	End Sub
+
 	Sub Save(filename As PCWSTR, encoder As Imaging.ImageCodecInfo, encoderParams As Imaging.EncoderParameters)
 		SaveImpl(filename, encoder.Clsid, ToNativeEncoderParameters(encoderParams))
