全然更新しないブログ
HSPメモ帳
「GDI+」で画像表示
「GDI+(Flat function)を利用した画像表示」
画像の表示テスト |
/////////////////////////////////////////////////////////////// #module pic_load #uselib "gdiplus.dll" #func GdiplusStartup "GdiplusStartup" var,var,int #func GdipLoadImageFromFile "GdipLoadImageFromFile" var,var #func GdipCreateFromHDC "GdipCreateFromHDC" int,var #func GdipDeleteGraphics "GdipDeleteGraphics" var #func GdipDrawImage "GdipDrawImageI" var,var,int,int #func GdipDrawImageR "GdipDrawImageRectI" var,var,int,int,int,int #func GdipDisposeImage "GdipDisposeImage" var #func GdiplusShutdown "GdiplusShutdown" var #defcfunc GDIpStartup dim GdiplusStartupInput,4 GdiplusStartupInput(0) = 1,0,0,0 GdiplusStartup token,GdiplusStartupInput,0 return token #defcfunc GDIpLoadFile str fn sdim wfn,520 cnvstow wfn,fn GdipLoadImageFromFile wfn,pImage return pImage #deffunc GDIpDispose var img GdipDisposeImage img return #deffunc GDIpShutdown var t GdiplusShutdown t return #deffunc GDIpImage var img,int x,int y GdipCreateFromHDC hdc, pGraphics dupptr Graphics,pGraphics,4 GdipDrawImage Graphics,img,x,y GdipDeleteGraphics Graphics return #deffunc GDIpImageEx var img,int x,int y,int w,int h GdipCreateFromHDC hdc, pGraphics dupptr Graphics,pGraphics,4 GdipDrawImageR Graphics,img,x,y,w,h GdipDeleteGraphics Graphics return ///////////////////////////////////////////////////////// // 現在のウィンドウに任意の位置、任意の大きさで描画 #defcfunc GdipLoad str fn,int x, int y,int w,int h token = GDIpStartup() if( token ){ pImage = GDIpLoadFile(fn) if( pImage ){ dupptr Image,pImage,4 GDIpImageEx Image,x,y,w,h GDIpDispose Image } } GDIpShutdown token return ret #global /////////////////////////////////////////////////////////////// // 落書き buffer 1 randomize gettime(7) repeat 100 color rnd(255),rnd(255),rnd(255) x=rnd(640) : y=rnd(480) boxf x-100,y-100,x+100,y+100 loop // メイン画面 screen 0,640,480 : title "Sample PIC_LOAD" onexit *on_exit // ファイルロード token = GDIpStartup() picName = "hsphelp/hhx_img/ar_fwd2.png" repeat pImage = GDIpLoadFile(picName) if( pImage ) : break dialog "",16 : picName = refstr if( stat != 1 ) : goto *on_exit loop dupptr image,pImage,4,4 // メインループ 描画 *main redraw 0 color : boxf gcopy 1,0,0,640,480 GDIpImageEx image,x,250,100,100 x+=1 : if( x>640 ) : x = 0 redraw 1 : wait 1 goto *main // 終了時の解放処理 *on_exit GDIpDispose image GDIpShutdown token end |
コメント ( 0 ) | Trackback ( 0 )