' load png image sample with FBImage. link BinaryFile.o ' ' ld -r -b binary -o image_png.o image_png.png ' fbc loadpngld.bas image_png.o ' ' Windows10 x64 22H2 + FreeBASIC 1.10.1 32bit + FBImage + ld 2.28 32bit ' Last updated: <2024/02/04 21:21:09 +0900> ' 画像読み込み用ライブラリ FBImage を使う #include once "FBImage.bi" ' カレントディレクトリを exeファイルのある場所にする chdir exepath() ' リンクしたバイナリオブジェクトの先頭アドレスと終了アドレス #If defined( __FB_WIN32__ ) And Not defined( __FB_64BIT__ ) ' Windows 32bit extern image_png_png_start alias "binary_image_png_png_start" as byte extern image_png_png_end alias "binary_image_png_png_end" as byte #Else ' Windows 64bit and other extern image_png_png_start alias "_binary_image_png_png_start" as byte extern image_png_png_end alias "_binary_image_png_png_end" as byte #endif ' デスクトップ解像度を指定 Dim As Integer scrw = 512 Dim As Integer scrh = 288 ' ウインドウサイズと色深度(bpp)を指定 screenres scrw, scrh, 32 ' バイナリデータの先頭アドレスとサイズを取得 dim as byte ptr imgdata = @image_png_png_start dim as Integer imgdata_length = @image_png_png_end - @image_png_png_start ' メモリ上にある画像データを FBImage で読み込む。ポインタとバイト数を渡す var img = LoadRGBAMemory(imgdata, imgdata_length) ' 画像を描画。RGB=(255, 0, 255) のピクセルは透明色として扱う Put (16, 16), img, TRANS ' キー入力があるまで待ち続ける sleep ' 画像を使い終わったので破棄 ImageDestroy img