Loading A Graphic Using CxImage From User Input
- Posted by Andy Jun 22, 2009
- 1390 views
Hey Guys,
Sorry for the long title, but I am in trouble. In my program Frost, I need to have it so a user can load a graphic file if his/her own and then have it displayed in the window inside of a group box. I am using the cxImage library so that the users can have more than just .bmp, anyways, here is my code.
procedure Add_Hero_WalkGfx(integer self, integer event, sequence parm) fName = getOpenFileName(EDWin,file,GraphicType) if length(fName) = 0 then return end if handle = open(fName,"rb") if handle = -1 then fn = message_box("File Load Error", "File Error", MB_TASKMODAL) end if while 1 do data = gets(handle) if atom(data) then exit end if data = data[1..length(data)-1] buffer = buffer & data end while close(handle) HeroWalk_Gfx = CXI_LoadImage(file, CXI_FORMAT_UNKNOWN,0) CXI_Resize(HeroWalk_Gfx,120,100,CXI_GOOD_RESIZE) end procedure setHandler(Hero_WalkGfx_Add,w32HClick,routine_id("Add_Hero_WalkGfx"))
I have declared some of the varialbes outside of the procedure, so don't worry about the variables not being declared.