Re: Using GDI Plus with Win32Lib

new topic     » goto parent     » topic index » view thread      » older message » newer message

Slimmed down code.. same results..

--testGDI-01.exw 
-- 1-9-2012 
 
 
include machine.e 
include misc.e 
include Win32Lib.ew 
include dll.e 
include wildcard.e 
include gdiplus_Win98,XP.ew 
 
without warning 
 
sequence screenSize screenSize =  getCtlSize( Screen )			-- get screen size 
global integer screenWidth screenWidth = screenSize[1]			-- width 
global integer screenHeight screenHeight = screenSize[2]		-- height 
integer winWidth winWidth = 1280								-- MAIN WINDOW WIDTH 
integer winHeight winHeight = 900								-- MAIN WINDOW WIDTH 
integer xWinPos xWinPos = floor((screenWidth - winWidth)/2)		-- x postion on display for centering MAIN WINDOW 
integer yWinPos yWinPos = floor((screenHeight - winHeight)/2)	-- y postion on display 
 
constant win = createEx( Window, "Relatives", 0, xWinPos, yWinPos, winWidth, winHeight, 0, 0 ), 
	 CrLf    = { '\r', '\n' } 
 
--************ GdiPlus Specific code *************** 
global atom status,ppGraphics,ppImage,pGraphics,pImage 
status=GdipInitialize() 
if status!=0 then puts(1,"Cant open a required dll\n") sleep(1) end if 
--pointer vars for use with images 
pImage=0 
ppGraphics=allocate(4) 
ppImage=allocate(4) 
 
procedure DoGraphics() 
puts(1,w32ToString(win)) puts(1,CrLf) 
	sequence FilePath,FileName 
	atom Width,Height,pUINT,status,x,y 
	object lpFilePathW 
	atom wH 
--wH=getHandle(win)				-- no image 
--wH=getHandle("win")				-- error message, but continue puts partial image is on desktop 
--wH=getHWND(win)					-- no image 
--wH=getHWND("win")					-- error 
wH=getId(win)						-- partial image is on desktop 
--wH=getMainWindow()				-- partial image is on desktop 
--wH=getIdName(win)					-- error 
--wH=getIdName("win")				-- error 
--wH=getNameId(win)					-- error 
--wH=getNameId("win")				-- partial image is on desktop 
--wH=getNameIdInContext("win", win)	-- partial image is on desktop 
puts(1,w32ToString(wH)) puts(1,CrLf) 
-- **************** from GDI ***************** 
--constant xGdipCreateFromHWND=lF(gdiplus,"GdipCreateFromHWND",{CP,CP},CL) 
--global function GdipCreateFromHWND(atom hwnd,atom pp_graphics) 
--   --(HWND hwnd,GpGraphics **graphics) 
--  if gdiplus>0 then 
--    return c_func(xGdipCreateFromHWND,{hwnd,pp_graphics}) 
--  else 
--    return 0 
--  end if 
--end function 
	status=GdipCreateFromHWND(wH,ppGraphics) 
puts(1,w32ToString(status)) puts(1,CrLf) 
	if status=0 then 
	  pGraphics=peek4u(ppGraphics) --the graphics object has been created. 
puts(1,w32ToString(pGraphics)) puts(1,CrLf) 
	else 
	  pGraphics=0 
	end if 
	FilePath="H:\\Euphoria\\relatives\\Genealogy\\JPark.jpg" 
	if length(FilePath)>0 then 
    --release old pic 
    	status=GdipDisposeImage(pImage) 
    --load the file 
    	lpFilePathW=AnsiToUnicode(FilePath) 
    	status=GdipLoadImageFromFile(lpFilePathW,ppImage) 
    	FreeUnicode(lpFilePathW) 
    	if status=0 then 
      		pImage=peek4u(ppImage) 
 puts(1,w32ToString(pImage)) puts(1,CrLf) 
    	else 
      		pImage=0       
    	end if 
  	end if 
  	pUINT=allocate(4) 
  	status=GdipGetImageWidth(pImage,pUINT) 
	Width=peek4u(pUINT) 
 	status=GdipGetImageHeight(pImage,pUINT) 
 	Height=peek4u(pUINT) 
  --Width=Width/2 
  --Height=Height/2 
 puts(1,w32ToString(Width)) puts(1,CrLf)		-- puts correct size 
 puts(1,w32ToString(Height)) puts(1,CrLf)		-- puts correct size 
-- ************* from GDI ************** 
--constant xGdipDrawImageRectI=lF(gdiplus,"GdipDrawImageRectI",{CP,CP,CI,CI,CI,CI},CL) 
--global function GdipDrawImageRectI(atom p_graphics,atom p_image,atom x,atom y,atom width,atom height) 
--    --(GpGraphics *graphics,GpImage *image,INT x,INT y,INT width,INT height) 
--  if gdiplus>0 then 
--    return c_func(xGdipDrawImageRectI,{p_graphics,p_image,x,y,width,height}) 
--  else 
--    return 0 
--  end if 
--end function 
  	status=GdipDrawImageRectI(pGraphics,pImage, 40,20,Width,Height) 
puts(1,w32ToString(status)) puts(1,CrLf) 
  	free(pUINT) 
	free(ppGraphics) 
	free(ppImage) 
end procedure 
------------------------------------------------------------------------------ 
DoGraphics() 
WinMain(win,Normal)  
   

Buzzo

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu