set ImageFormat and PixelFormat in contstuctors, GetDeviceCaps function and parameters
authorAlexandre Pigolkine <pigolkine@mono-cvs.ximian.com>
Sat, 23 Aug 2003 09:39:37 +0000 (09:39 -0000)
committerAlexandre Pigolkine <pigolkine@mono-cvs.ximian.com>
Sat, 23 Aug 2003 09:39:37 +0000 (09:39 -0000)
svn path=/trunk/mcs/; revision=17534

mcs/class/System.Drawing/System.Drawing/impl/wine/Bitmap.cs
mcs/class/System.Drawing/System.Drawing/impl/wine/ChangeLog
mcs/class/System.Drawing/System.Drawing/impl/wine/win32Enums.cs
mcs/class/System.Drawing/System.Drawing/impl/wine/win32functions.cs

index 52c038bb45115e6ca0a1fac239bbf02336a8801d..ddc17b00b28cff820629443d7b491421eece8a5b 100644 (file)
@@ -72,6 +72,19 @@ namespace System.Drawing {
                                IntPtr hdc = g.GetHdc();
                                nativeObject_ = Win32.CreateCompatibleBitmap(hdc, width, height);
                                imageSize_ = new Size(width, height);
+                               imageFormat_ = ImageFormat.Bmp;
+                               // FIXME: shall we get pixel format from device or just set PixelFormat.Format32bppArgb
+                               switch (Win32.GetDeviceCaps (g.GetHdc(), GetDeviceCapsParams.BITSPIXEL)){
+                                       case 32:
+                                               pixelFormat_ = PixelFormat.Format32bppArgb;
+                                               break;
+                                       case 24:
+                                               pixelFormat_ = PixelFormat.Format24bppRgb;
+                                               break;
+                                       default:
+                                               pixelFormat_ = PixelFormat.Format32bppArgb;
+                                               break;
+                               }
                                g.ReleaseHdc(hdc);
                        }
 
@@ -79,6 +92,7 @@ namespace System.Drawing {
                        {
                                IntPtr hdc = Win32.GetDC(IntPtr.Zero);
                                pixelFormat_ = format;
+                               imageFormat_ = ImageFormat.Bmp;
                                BITMAPINFO_FLAT bmi = new BITMAPINFO_FLAT();
                                bmi.bmiHeader_biSize = 40;
                                bmi.bmiHeader_biWidth = width;
index c63e8ab3833f43847287844139f4e652ad97e998..69506880ff7cb9ef2cca9265b824bf8ec0201b6e 100644 (file)
@@ -1,3 +1,9 @@
+2003-08-23 Alexandre Pigolkine
+       * Bitmap.cs                     set ImageFormat and PixelFormat in contstuctors
+       * win32Enums.cs         
+       * win32functions.cs             GetDeviceCaps function and parameters
+                               
+
 2003-08-06  Duncan Mak  <duncan@ximian.com>
 
        * Bitmap.cs: 
index 38864634eab300c919b6dc3ab711e8ed9d8ae94b..7a2ed71600703af3559597018a5653a0b659915c 100644 (file)
@@ -2399,4 +2399,36 @@ namespace System.Drawing.Win32Impl {
                DIB_RGB_COLORS = 0,
                DIB_PAL_COLORS = 1
        }
+       
+       internal enum GetDeviceCapsParams : int {
+               DRIVERVERSION     =0,
+               TECHNOLOGY        =2,
+               HORZSIZE          =4,
+               VERTSIZE          =6,
+               HORZRES           =8,
+               VERTRES           =10,
+               BITSPIXEL         =12,
+               PLANES            =14,
+               NUMBRUSHES        =16,
+               NUMPENS           =18,
+               NUMMARKERS        =20,
+               NUMFONTS          =22,
+               NUMCOLORS         =24,
+               PDEVICESIZE       =26,
+               CURVECAPS         =28,
+               LINECAPS          =30,
+               POLYGONALCAPS     =32,
+               TEXTCAPS          =34,
+               CLIPCAPS          =36,
+               RASTERCAPS        =38,
+               ASPECTX           =40,
+               ASPECTY           =42,
+               ASPECTXY          =44,
+               LOGPIXELSX        =88,
+               LOGPIXELSY        =90,
+               CAPS1             =94,
+               SIZEPALETTE       =104,
+               NUMRESERVED       =106,
+               COLORRES          =108
+       }
 }
index 8b69f7bd4309cc046f324494ca778b6add193e45..2d1978846079910d641a151c514a4b1036b52ffd 100644 (file)
@@ -143,6 +143,11 @@ namespace System.Drawing.Win32Impl {
                         CallingConvention = CallingConvention.StdCall, 
                         CharSet = CharSet.Ansi)]
                internal static extern int GdiFlush();
+
+               [DllImport ("gdi32.dll", 
+                        CallingConvention = CallingConvention.StdCall, 
+                        CharSet = CharSet.Ansi)]
+               internal static extern int GetDeviceCaps (IntPtr hdc, GetDeviceCapsParams index);
                
                #endregion