Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to save DC to bitmap file?
Message
De
18/07/2004 06:10:12
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
How to save DC to bitmap file?
Divers
Thread ID:
00925557
Message ID:
00925557
Vues:
58
Hi,
I wrote code to change color in bitmap. I going to save result to bitmap file.. but can't understand yet how can I do that with using Win32API.
I have some C++ examples.. but have't ideas how to convert it to win32Api
calls

Thanks for your help!
There my code

DECLARE INTEGER LoadBitmap IN WIN32API INTEGER @, STRING lcBitmapFile
DECLARE INTEGER SelectObject IN WIN32API As SelectObjectA INTEGER , INTEGER 
DECLARE INTEGER GetPixel IN WIN32API INTEGER lnHDC, INTEGER lnX, INTEGER lnY
DECLARE INTEGER SetPixel IN WIN32API INTEGER lnHDC, INTEGER lnX, INTEGER lnY, INTEGER lnRGB
DECLARE INTEGER CreateCompatibleDC IN WIN32API INTEGER lnHDC
DECLARE INTEGER GetObject IN WIN32API As GetObjectA INTEGER lnHBitmap, INTEGER lnSize, STRING @lcBitmap
DECLARE INTEGER DeleteDC IN WIN32API INTEGER


DECLARE INTEGER LoadImage IN WIN32API ;
	INTEGER @hinst,;
    STRING lpszName,;
    INTEGER uType,;
    INTEGER cxDesired,;
    INTEGER cyDesired,;
    INTEGER fuLoad
    
#DEFINE IMAGE_BITMAP 0
#define LR_DEFAULTCOLOR     0x0000
#define LR_MONOCHROME       0x0001
#define LR_COLOR            0x0002
#define LR_COPYRETURNORG    0x0004
#define LR_COPYDELETEORG    0x0008
#define LR_LOADFROMFILE     0x0010
#define LR_LOADTRANSPARENT  0x0020
#define LR_DEFAULTSIZE      0x0040
#define LR_VGACOLOR         0x0080
#define LR_LOADMAP3DCOLORS  0x1000
#define LR_CREATEDIBSECTION 0x2000
#define LR_COPYFROMRESOURCE 0x4000
#define LR_SHARED           0x8000

lnParam = BITOR(LR_DEFAULTSIZE,LR_DEFAULTCOLOR,LR_LOADFROMFILE)

LOCAL lnInstance
lnInstance = 0
LOCAL lnDC
lnHDC = 0
lcPictureFile = GETPICT("bmp")
lnHBitmap = LoadImage(@lnInstance,lcPictureFile,IMAGE_BITMAP,0,0,lnParam)
cBuff = REPLICATE(SPACE(1),4*5+4*2)
lnSize = LEN(cBuff)
IF lnHBitmap!=0
	lnObject = GetObjectA(lnHBitmap,lnSize,@cBuff)
	
lnType = ALLTRIM(STR(ASC(SUBSTR(cBuff,4)) * 256 + ASC(SUBSTR(cBuff,1))))
lnWIdth= ALLTRIM(STR(ASC(SUBSTR(cBuff,8)) * 256 + ASC(SUBSTR(cBuff,5))))
lnHeight = ALLTRIM(STR(ASC(SUBSTR(cBuff,12)) * 256 + ASC(SUBSTR(cBuff,9))))
lnWidthBytes = ALLTRIM(STR(ASC(SUBSTR(cBuff,16)) * 256 + ASC(SUBSTR(cBuff,13))))
lnPlanes = ALLTRIM(STR(ASC(SUBSTR(cBuff,20)) * 256 + ASC(SUBSTR(cBuff,17))))
lnBitsPixel =ALLTRIM(STR(ASC(SUBSTR(cBuff,24)) * 256 + ASC(SUBSTR(cBuff,21))))
lnBits = ALLTRIM(STR(ASC(SUBSTR(cBuff,28)) * 256 + ASC(SUBSTR(cBuff,25))))
	
lnHDC = CreateCompatibleDC(0)
lnHImg = SelectObjectA(lnHDC,lnHBitmap)

	FOR lni=1 TO VAL(lnWidth)
		FOR Lnj=1 TO VAL(lnHeight)
			lnRGB = GetPixel(lnHDC,lni,lnj)
			IF lnRGB = RGB(0,0,0)
				SetPixel(lnHDC,lni,lnj,RGB(255,0,0))
			ENDIF
		ENDFOR
	ENDFOR
ENDIF


** There I need some code to save result into Bitmap

DeleteDC(lnHDC)
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform