{
#region constructors
// constructors
- public Bitmap (int width, int height)
+ public Bitmap (int width, int height) : this( width, height, PixelFormat.Format32bppArgb)
{
}
g.ReleaseHdc(hdc);
}
- public Bitmap (int width, int heigth, System.Drawing.Imaging.PixelFormat format) {
- throw new NotImplementedException ();
+ public Bitmap (int width, int height, System.Drawing.Imaging.PixelFormat format) {
+ IntPtr hdc = Win32.GetDC(IntPtr.Zero);
+ pixelFormat_ = format;
+ BITMAPINFO_FLAT bmi = new BITMAPINFO_FLAT();
+ bmi.bmiHeader_biSize = 40;
+ bmi.bmiHeader_biWidth = width;
+ bmi.bmiHeader_biHeight = height;
+ bmi.bmiHeader_biPlanes = 1;
+ bmi.bmiHeader_biBitCount = (short)System.Drawing.Image.GetPixelFormatSize(pixelFormat_);
+ bmi.bmiHeader_biCompression = 0;
+ bmi.bmiHeader_biSizeImage = 0;
+ bmi.bmiHeader_biXPelsPerMeter = 0;
+ bmi.bmiHeader_biYPelsPerMeter = 0;
+ bmi.bmiHeader_biClrUsed = 0;
+ bmi.bmiHeader_biClrImportant = 0;
+ IntPtr bitsPtr;
+ nativeObject_ = Win32.CreateDIBSection(hdc, ref bmi, DibUsage.DIB_RGB_COLORS,
+ out bitsPtr, IntPtr.Zero, 0);
+ imageSize_ = new Size(width, height);
+ Win32.ReleaseDC( IntPtr.Zero, hdc);
}
public Bitmap (Image origial) {
Win32.DeleteDC(memDC);
imageSize_ = info.Size;
imageFormat_ = info.RawFormat;
+ pixelFormat_ = info.Format;
}
}
+2003-06-27 Alexandre Pigolkine <pigolkine@gmx.de>
+ * FontFamily.cs added
+ * Graphics.cs DrawLine functions
+ * Bitmap.cs create HBITMAP in constructor
+ * Image.cs create InternalImageInfo from HBITMAP
+
2003-06-15 Alexandre Pigolkine <pigolkine@gmx.de>
* Graphics.cs image painting
* Bitmap.cs
--- /dev/null
+//
+// System.Drawing.Win32Impl.FontFamily.cs
+//
+// Author:
+// Alexandre Pigolkine (pigolkine@gmx.de)
+//
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Text;
+
+namespace System.Drawing {
+ namespace Win32Impl {
+
+ internal class FontFamilyFactory : IFontFamilyFactory {
+
+ IFontFamily IFontFamilyFactory.FontFamily(GenericFontFamilies genericFamily){
+ return new Win32FontFamily(genericFamily);
+ }
+
+ IFontFamily IFontFamilyFactory.FontFamily(string familyName){
+ return new Win32FontFamily(familyName);
+ }
+
+ IFontFamily IFontFamilyFactory.FontFamily( string familyName, FontCollection collection){
+ return new Win32FontFamily(familyName,collection);
+ }
+
+ IFontFamily[] IFontFamilyFactory.GetFamilies(System.Drawing.Graphics graphics) {
+ throw new NotImplementedException();
+ }
+
+ }
+
+ internal class Win32FontFamily : MarshalByRefObject, IFontFamily
+ {
+ string name;
+ static Win32FontFamily genericMonospace;
+ static Win32FontFamily genericSansSerif;
+ static Win32FontFamily genericSerif;
+
+ public Win32FontFamily(GenericFontFamilies genericFamily) {
+ throw new NotImplementedException();
+ }
+
+ public Win32FontFamily(string familyName) {
+ name = familyName;
+ }
+
+ public Win32FontFamily(string familyName, FontCollection collection) {
+ name = familyName;
+ }
+
+ public string Name {
+ get {
+ return name;
+ }
+ }
+
+ public int GetCellAscent (FontStyle style) {
+ return 0;
+ }
+
+ public int GetCellDescent (FontStyle style) {
+ return 0;
+ }
+
+ public int GetEmHeight (FontStyle style) {
+ return 0;
+ }
+
+ public int GetLineSpacing (FontStyle style) {
+ return 0;
+ }
+
+ public bool IsStyleAvailable (FontStyle style){
+ return false;
+ }
+
+ public void Dispose() {
+ }
+ }
+ }
+}
throw new NotImplementedException ();
}
+ void DrawLine (Pen winePen, int x1, int y1, int x2, int y2)
+ {
+ POINT[] pts = new POINT[2];
+ pts[0].x = x1;
+ pts[0].y = y1;
+ pts[1].x = x2;
+ pts[1].y = y2;
+ IntPtr oldPen = Win32.SelectObject(hdc_, winePen.hpen_);
+ Win32.Polyline( hdc_, pts, 2);
+ Win32.SelectObject(hdc_, oldPen);
+ }
+
[MonoTODO]
void IGraphics.DrawLine (System.Drawing.Pen pen, PointF pt1, PointF pt2)
{
- throw new NotImplementedException ();
+ DrawLine( ConvertPen(pen), (int)pt1.X, (int)pt1.Y, (int)pt2.X, (int)pt2.Y);
}
[MonoTODO]
void IGraphics.DrawLine (System.Drawing.Pen pen, Point pt1, Point pt2)
{
- throw new NotImplementedException ();
+ DrawLine( ConvertPen(pen), (int)pt1.X, (int)pt1.Y, (int)pt2.X, (int)pt2.Y);
}
[MonoTODO]
void IGraphics.DrawLine (System.Drawing.Pen pen, int x1, int y1, int x2, int y2)
{
- throw new NotImplementedException ();
+ DrawLine( ConvertPen(pen), x1, y1, x2, y2);
}
[MonoTODO]
void IGraphics.DrawLine (System.Drawing.Pen pen, float x1, float y1, float x2, float y2)
{
- throw new NotImplementedException ();
+ DrawLine( ConvertPen(pen), (int)x1, (int)y1, (int)x2, (int)y2);
}
[MonoTODO]
void IGraphics.DrawLines (System.Drawing.Pen pen, PointF [] points)
{
- throw new NotImplementedException ();
+ //throw new NotImplementedException ();
}
[MonoTODO]
[MonoTODO]
void IGraphics.Restore (GraphicsState gstate)
{
- throw new NotImplementedException ();
+ //throw new NotImplementedException ();
}
[MonoTODO]
void IGraphics.RotateTransform (float angle)
{
- throw new NotImplementedException ();
+ //throw new NotImplementedException ();
}
[MonoTODO]
[MonoTODO]
public GraphicsState Save ()
{
- throw new NotImplementedException ();
+ //throw new NotImplementedException ();
+ return new GraphicsState();
}
[MonoTODO]
[MonoTODO]
void IGraphics.TranslateTransform (float dx, float dy)
{
- throw new NotImplementedException ();
+ //throw new NotImplementedException ();
}
[MonoTODO]
using System.Runtime.Serialization;
using System.Drawing.Imaging;
using System.IO;
+ using System.Runtime.InteropServices;
//[Serializable]
//[ComVisible(true)]
protected Size imageSize_;
protected ImageFormat imageFormat_;
+ protected PixelFormat pixelFormat_;
// constructor
public Image () {}
protected InternalImageInfo createdFrom_ = null;
public InternalImageInfo ConvertToInternalImageInfo() {
InternalImageInfo result = new InternalImageInfo();
+ IntPtr hTempBitmap = IntPtr.Zero;
+ IntPtr hdc = IntPtr.Zero;
+ result.Size = imageSize_;
+ result.Format = pixelFormat_;
+ //result.Stride =
+ if(selectedIntoGraphics_ != null) {
+ hdc = selectedIntoGraphics_.GetHdc();
+ hTempBitmap = Win32.CreateCompatibleBitmap(hdc,1,1);
+ Win32.SelectObject( hdc, hTempBitmap);
+ }
+ else {
+ hdc = Win32.GetDC(IntPtr.Zero);
+ }
//nativeObject_;Win32.GetDIBits();
- return createdFrom_;
+ BITMAPINFO_FLAT bmi = new BITMAPINFO_FLAT();
+ bmi.bmiHeader_biSize = 40;
+ bmi.bmiHeader_biWidth = imageSize_.Width;
+ bmi.bmiHeader_biHeight = imageSize_.Height;
+ bmi.bmiHeader_biPlanes = 1;
+ bmi.bmiHeader_biBitCount = (short) System.Drawing.Image.GetPixelFormatSize(pixelFormat_);
+ bmi.bmiHeader_biCompression = 0;
+ bmi.bmiHeader_biSizeImage = 0;
+ bmi.bmiHeader_biXPelsPerMeter = 0;
+ bmi.bmiHeader_biYPelsPerMeter = 0;
+ bmi.bmiHeader_biClrUsed = 0;
+ bmi.bmiHeader_biClrImportant = 0;
+
+ int res = Win32.GetDIBits(hdc, nativeObject_, 0, imageSize_.Height, 0, ref bmi, (int)DibUsage.DIB_RGB_COLORS);
+ if( res != 0) {
+ IntPtr nativeBits = Marshal.AllocHGlobal(bmi.bmiHeader_biSizeImage);
+ res = Win32.GetDIBits(hdc, nativeObject_, 0, imageSize_.Height, nativeBits.ToInt32(), ref bmi, (int)DibUsage.DIB_RGB_COLORS);
+ result.RawImageBytes = new byte[bmi.bmiHeader_biSizeImage];
+ Marshal.Copy( nativeBits, result.RawImageBytes, 0, bmi.bmiHeader_biSizeImage);
+ Marshal.FreeHGlobal(nativeBits);
+ }
+ else {
+ uint err = Win32.GetLastError();
+ }
+
+ if(selectedIntoGraphics_ != null) {
+ Win32.SelectObject( hdc, nativeObject_);
+ Win32.DeleteObject(hTempBitmap);
+ selectedIntoGraphics_.ReleaseHdc(hdc);
+ }
+ else {
+ Win32.ReleaseDC(IntPtr.Zero,hdc);
+ }
+ return result;
}
public void Save (string filename)