Schoeni, Yann wrote:
>  
>
> I don’t see anything about color depth in the script, do you think I
> should define it somewhere ?
>
>  
>
> I did this to check that everything was correct before the image was
> draw :
>
>  
>
> bmp = Image.open (file_name)
>
> print(bmp.mode)
>
>  
>
> The return value is : RGB
>
> In the PIL documentation I’ve found : RGB (3x8-bit pixels, true color)
>
>  
>
> Which means 24-bits depth, correct ?
>

Correct.


> Now I need to create the device context as a 24-bits.
>
>  
>
>
>       i've done some research but, I didn’t find how to set the depth
>       color manually ..
>
>
>        
>
>
>       If I do :
>
>
>        
>
>
>       NUMCOLORS = 0
>
>
>        
>
>
>       hDC = win32.CreateDC()
>
>
>       hDC.CreatePrinterDC (printer_name)
>
>
> colorDepth = hDC.GetDeviceCaps(NUMCOLORS)
>
> print("colorDepth : ", colorDepth);
>
>  
>
> The return value is : colorDepth : 1539
>

Where did you get "NUMCOLORS = 0"?  That's wrong:

/* Device Parameters for GetDeviceCaps() */
#define DRIVERVERSION 0     /* Device driver version                    */
#define TECHNOLOGY    2     /* Device classification                    */
#define HORZSIZE      4     /* Horizontal size in millimeters           */
#define VERTSIZE      6     /* Vertical size in millimeters             */
#define HORZRES       8     /* Horizontal width in pixels               */
#define VERTRES       10    /* Vertical height in pixels                */
#define BITSPIXEL     12    /* Number of bits per pixel                 */
#define PLANES        14    /* Number of planes                         */
#define NUMBRUSHES    16    /* Number of brushes the device has         */
#define NUMPENS       18    /* Number of pens the device has            */
#define NUMMARKERS    20    /* Number of markers the device has         */
#define NUMFONTS      22    /* Number of fonts the device has           */
#define NUMCOLORS     24    /* Number of colors the device supports     */
etc

So, your 1539 result says that the driver's version is 0x0603.  You
don't need to hardcode these numbers at all.  Most Windows constants are
in win32con.  Plus, the important number is BITSPIXEL.  If that is 8,
then you can look at NUMCOLORS.  If it is not 8, then NUMCOLORS is not
meaningful.
     import win32con
     print( hDC.GetDeviceCaps(win32con.BITSPIXEL))
     print( hDC.GetDeviceCaps(win32con.NUMCOLORS))

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to