Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GDI - Change colordepth for BMP file
Message
From
21/10/2005 16:58:53
 
 
To
21/10/2005 16:34:58
General information
Forum:
Visual FoxPro
Category:
Pictures and Image processing
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01061230
Message ID:
01061299
Views:
9
Hi Johann,

Sorry, I did not test the previous code I sent.
The whole problem was on the GDIPLUS_PIXELFORMAT_16bppARGB1555

I changed to GDIPLUS_PIXELFORMAT_16bppRGB565, and It's working fine for me.
If you have problems, try changing to another constant provided for 16bpp.

The default for _gdiplus.vcx is GDIPLUS_PIXELFORMAT_32bppARGB, that returns the best results, but you need 16bpp.

Now try this one !

Regards
Cesar
#define	GDIPLUS_PIXELFORMAT_1bppIndexed     	0x00030101
#define	GDIPLUS_PIXELFORMAT_4bppIndexed     	0x00030402
#define	GDIPLUS_PIXELFORMAT_8bppIndexed     	0x00030803
#define	GDIPLUS_PIXELFORMAT_16bppGrayScale  	0x00101004
#define	GDIPLUS_PIXELFORMAT_16bppRGB555     	0x00021005
#define	GDIPLUS_PIXELFORMAT_16bppRGB565     	0x00021006
#define	GDIPLUS_PIXELFORMAT_16bppARGB1555   	0x00061007
#define	GDIPLUS_PIXELFORMAT_24bppRGB        	0x00021808
#define	GDIPLUS_PIXELFORMAT_32bppRGB        	0x00022009
#define	GDIPLUS_PIXELFORMAT_32bppARGB       	0x0026200A
#define	GDIPLUS_PIXELFORMAT_32bppPARGB      	0x000E200B
#define	GDIPLUS_PIXELFORMAT_48bppRGB        	0x0010300C
#define	GDIPLUS_PIXELFORMAT_64bppPARGB      	0x001C400E


lcSource = GETPICT()
lcDestination = "c:\test.bmp"

SET PATH TO HOME(1)

LOCAL loImage AS GpImage of ffc/_gdiplus.vcx
loImage = NEWOBJECT("GpImage", "FFC\_gdiplus.vcx")
loImage.CreateFromFile(lcSource)

LOCAL loBitmap AS GpBitmap of ffc/_gdiplus.vcx
loBitmap = NEWOBJECT("GpBitmap", "ffc/_gdiplus.vcx")
LOCAL loGraphics as GpGraphics of ffc/_gdiplus.vcx
loGraphics = NEWOBJECT('GpGraphics','ffc/_gdiplus.vcx')

*** Now we create a new image with 
*** Create Method - Creates a bitmap object. 
*** Syntax: ? THIS.Create(tnWidth, tnHeight[, tnPixelFormat])
***
***tnPixelFormat, optional, one of GDIPLUS_PIXELFORMAT_* constants, 
***      defaults to GDIPLUS_PIXELFORMAT_32bppARGB.

loBitmap.Create(324,198,GDIPLUS_PIXELFORMAT_16bppRGB565) && The size you specified
*** The other constants are in the beginning of this code

loGraphics.CreateFromImage(loBitmap)
loGraphics.DrawImageScaled(loImage, 0, 0, 324, 198)
loBitmap.SaveToFile(lcDestination, "image/bmp")
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform