Re: Loading A Graphic Using CxImage From User Input

new topic     » goto parent     » topic index » view thread      » older message » newer message
ghaberek said...
Andy said...

Ah, I used your code, but it still crahses. However the error says that there is a type_check failure. image type is {71,114,97,112...}

I am using a supported image type, so what is up?

Your GraphicType value needs to be one of these constants, from CxImage.ew:

-- Image types. Used with CXI_LoadImage and CXI_SaveImage.
global constant CXI_FORMAT_UNKNOWN = 0, 
        CXI_FORMAT_BMP = 1, 
        CXI_FORMAT_GIF = 2, 
        CXI_FORMAT_JPG = 3, 
        CXI_FORMAT_PNG = 4, 
        CXI_FORMAT_ICO = 5, 
        CXI_FORMAT_TGA = 6, 
        CXI_FORMAT_PCX = 7 

I suspect you're passing it a sequence of "Grap..." something. (At least that's what your error message seems to indicate.)

-Greg

Thanks, it appears to be working now, however, the image is displayed as a grey box, and it paints over the other controls. I have tried repaintRect, but it still shows the grey box. Here is the new code

 
procedure Add_Hero_WalkGfx(integer self, integer event, sequence parm) 
	fName = getOpenFileName(EDWin,file,GraphicType) 
	 
	if length(fName) = 0 then 
		return 
	end if 
	 
	HeroWalk_Gfx = CXI_LoadImage(fName,CXI_FORMAT_UNKNOWN,0) 
	 
	HeroWalk_Gfx = createDIBFromCXImage(HeroWalk_Gfx) 
	 
	repaintRect(EDWin,750,220,64,64) 
end procedure 
setHandler(Hero_WalkGfx_Add,w32HClick,routine_id("Add_Hero_WalkGfx")) 
 
procedure EDWin_onPaint(integer self, integer event, sequence parm) 
	if HeroWalk_Gfx != 0 then 
		copyBlt(EDWin,750,220,HeroWalk_Gfx) 
	end if 
end procedure 
setHandler(EDWin,w32HPaint,routine_id("EDWin_onPaint")) 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu