> [hgimg4] に取り込んだ画像で、[pget] 同様のことを
という、当初の形のプログラムを組んでみました。
題して、『celbitmap=by_usagiさん+選択ダイアログ=by_TOMATOさん.hsp』
#include "hgimg4.as"
#uselib "Comdlg32.DLL"
#func GetOpenFileName "GetOpenFileNameA" int
#define BUFSIZE 260
#define FILTERSIZE 512
#define ALLTYPE "ALL files (*.*)@*.*@"
#define PICTURE "画像ファイル (*.bmp;*.mag;*.jpg;*.png)@*.bmp;*.mag;*.jpg;*.png@"
#define SOUND "音楽ファイル (*.mid;*.mp3;*.wav)@*.mid;*.mp3;*.wav@"
#define DOCUMENT "文書ファイル (*.txt)@*.txt@"
#define OFN_FILEMUSTEXIST $00001000
gpreset
setcls CLSMODE_SOLID, 0
chdir dir_exe+"\\sample\\hgimg4"
gosub *選択ダイアログ
//buffer 2, 640, 200, screen_offscreenr
buffer 2
picload filename, 0
//celload filename, 2
//celload "hsp3dish.png", 2
picW = ginfo(12) ; 仮想ウィンドウの横幅=画像の幅の取得。
picH = ginfo(13) ; 仮想ウィンドウの高さ=画像の高さ取得。
title ""+picW+" / "+picH
//stop
//dim vram, ginfo_sx*ginfo_sy
dim vram, picW*picH
;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
*MAIN
;====================
celbitmap 2, vram, celbitmap_capture // celbitmap_capture = 描画画面の内容を変数に読み出す
// pcol = vram(limit(mousex+(200-mousey)*640,0,length(vram)-1))
pcol = vram(limit(mousex+(picH-mousey)*picW,0,length(vram)-1))
col = (pcol>>24) & $FF, (pcol>>16) & $FF, (pcol>>8) & $FF, pcol & $FF
;====================
gsel 0
redraw 0
pos 0,0 : celput 2
pos mousex, mousey
color col.3, col.2, col.1
mes strf(" 色は(%3d,%3d,%3d)", col.3, col.2, col.1), 4
boxf mousex+20, mousey+20, mousex+60, mousey+60
title filename+" // "+mousex+" / "+mousey+" // "+strf(" 色は(%3d,%3d,%3d)", col.3, col.2, col.1)
redraw 1
await 32
goto *MAIN
;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
*選択ダイアログ
dim ofn , 22
sdim aplFilter , FILTERSIZE+1
sdim usrFilter , FILTERSIZE+1
sdim filename , BUFSIZE+1
aplFilter = PICTURE + SOUND + DOCUMENT + ALLTYPE + "@"
usrFilter = "ユーザ選択フィルタ (*.*)@*.*@" + "@"
repeat
await 0
mutch=instr(aplFilter,start,"@")
if mutch = -1 : break
poke aplFilter , start + mutch , $00
start += mutch + 1
loop
start = 0
repeat
await 0
mutch=instr(usrFilter,start,"@")
if mutch = -1 : break
poke usrFilter , start + mutch , $00
start += mutch + 1
loop
ofn.0 = 88 ; lStructSize
ofn.1 = hwnd ; hwndOwner
ofn.2 = hinstance ; hInstance
ofn.3=varptr(aplFilter) ; lpstrFilter
ofn.4=varptr(usrFilter) ; lpstrCustomFilter
ofn.5 = FILTERSIZE ; nMaxCustFilter
ofn.6 = 1 ; nFilterIndex
ofn.7=varptr(filename) ; lpstrFile
ofn.8 = BUFSIZE ; nMaxFile
ofn.9 = 0 ; lpstrFileTitle
ofn.10 = 0 ; nMaxFileTitle
ofn.11 = 0 ; lpstrInitialDir
ofn.12 = 0 ; lpstrTitle
ofn.13 = OFN_FILEMUSTEXIST ; Flags
prm=varptr(ofn)
GetOpenFileName prm
if stat = 0{
dialog "失敗" , 0 , "終了確認" : end
}
title filename
return