bmp²èÁü¤ËÆò½¤µ¤»¤¿picload³ÈÄ¥¥â¥¸¥å¡¼¥ë¤Ç¤¹¡£
°ì¸À¤Ç³ÈÄ¥»Ò¤¬bmp¤Î¥Õ¥¡¥¤¥ë¤È¸À¤Ã¤Æ¤â¤¤¤í¤ó¤Ê·Á¼°¤¬¤¢¤ê¡¢Ãæ¤Ë¤ÏHSP¤Ç¤ÏÆɤ߹þ¤á¤Ê¤¤bmp²èÁü¤â¤¢¤ê¤Þ¤¹¡£
¤³¤Î¥â¥¸¥å¡¼¥ë¤ò»È¤¨¤Ð¡¢¤Û¤ÜÁ´¤Æ¤Îbmp²èÁü¤òɽ¼¨¤µ¤»¤ë¤³¤È¤¬²Äǽ¤Ç¤¹¡£
#module
#deffunc bmppicload str m_filepath
actwid=ginfo(3)
filepath=m_filepath
exist filepath
tstrsize=strsize
sdim dt,tstrsize
bload filepath,dt
id=0
chk=wpeek(dt,id):id+=2
bitmapflg=0
if chk=19778{ ;bmp
paletteflg=0
bitfieldflg=0
dim colmask,4
dim maskshiftnum,4
dim maskshiftdir,4
mref bmscr,67
screentype=bmscr(17)
id+=8
offset=lpeek(dt,id):id+=4
headsize=lpeek(dt,id):id+=4
if headsize>=40{ ;BITMAPINFOHEADER
picwidth=lpeek(dt,id):id+=4
picheight=lpeek(dt,id):id+=4
id+=2
pixelbitnum=wpeek(dt,id):id+=2
if pixelbitnum<=8{
paletteflg=1
}
compressiontype=lpeek(dt,id):id+=4
id+=12
colidnum=lpeek(dt,id):id+=4
id+=4
}
if headsize>=52{ ;BITMAPV3INFOHEADER(V2¥Ø¥Ã¥À)
bitfieldflg=1
masknum=3
repeat 3:ctid=2-cnt
colmask(ctid)=lpeek(dt,id):id+=4
tcolmask=colmask(ctid)
repeat 32
if tcolmask>=256{ ;±¦¥·¥Õ¥È
tcolmask>>1
}else:if (tcolmask&128)=0{ ;º¸¥·¥Õ¥È
tcolmask<<1
maskshiftdir(ctid)=1
}else{
break
}
maskshiftnum(ctid)++
loop
loop
}
if headsize>=56{ ;BITMAPV3INFOHEADER(V3¥Ø¥Ã¥À)
masknum=4
ctid=3
colmask(ctid)=lpeek(dt,id):id+=4
tcolmask=colmask(ctid)
repeat 32
if tcolmask>=256{ ;±¦¥·¥Õ¥È
tcolmask>>1
}else:if (tcolmask&128)=0{ ;º¸¥·¥Õ¥È
tcolmask<<1
maskshiftdir(ctid)=1
}else{
break
}
maskshiftnum(ctid)++
loop
}
if headsize>=108{ ;BITMAPV4HEADER
id+=52
}
if headsize>=124{ ;BITMAPV5HEADER
id+=16
}
if compressiontype=3&(headsize!=52&headsize!=56&headsize!=124){ ;°µ½Ì¡Ê¥Ó¥Ã¥È¥Õ¥£¡¼¥ë¥É¡Ë
if masknum<3{
masknum=3
}
bitfieldflg=1
repeat 3:ctid=2-cnt
maskshiftnum(ctid)=0
colmask(ctid)=lpeek(dt,id):id+=4
tcolmask=colmask(ctid)
repeat 32
if tcolmask>=256{ ;±¦¥·¥Õ¥È
tcolmask>>1
}else:if (tcolmask&128)=0{ ;º¸¥·¥Õ¥È
tcolmask<<1
maskshiftdir(ctid)=1
}else{
break
}
maskshiftnum(ctid)++
loop
loop
}
if paletteflg{ ;¥«¥é¡¼¥Ñ¥ì¥Ã¥È
if screentype=1{
buffer actwid,picwidth,picheight,screen_palette
}else:if screentype=2{
screen actwid,picwidth,picheight,screen_palette
}else:if screentype=3{
bgscr actwid,picwidth,picheight,screen_palette
}
palcolnum=int(powf(2,pixelbitnum))
repeat palcolnum
b=peek(dt,id):id++
g=peek(dt,id):id++
r=peek(dt,id):id++
id++
palette cnt,r,g,b,0
loop
palette -1,,,,1
}else{ ;¥Õ¥ë¥«¥é¡¼
if screentype=1{
buffer actwid,picwidth,picheight
}else:if screentype=2{
screen actwid,picwidth,picheight
}else:if screentype=3{
bgscr actwid,picwidth,picheight
}
}
if compressiontype=1|compressiontype=2{ ;°µ½Ì·Á¼°¡ÊRLE¡Ë
rledtsize=tstrsize-id
sdim rlesizedt,1024
rlesizeid=0
waru=8/pixelbitnum
repeat
if id>=tstrsize:break
num=peek(dt,id):id++
chkbyte=peek(dt,id):id++
repeat num/waru
if rlesizeid>=varsize(rlesizedt){
memexpand rlesizedt,varsize(rlesizedt)+1024
}
memcpy rlesizedt,chkbyte,1,rlesizeid,0
rlesizeid++
loop
loop
imagedtsize=rlesizeid
sdim imagedt,imagedtsize
memcpy imagedt,rlesizedt,imagedtsize,0,0
}else{
imagedtsize=tstrsize-id
sdim imagedt,imagedtsize
memcpy imagedt,dt,imagedtsize,0,id
}
id=0
mref vram,66
if paletteflg{ ;¥Ñ¥ì¥Ã¥È¥«¥é¡¼
setbitlen=picwidth/4*4
if picwidth\4!=0{
setbitlen+4
}
getstwid=0
picwbitlen=picwidth*pixelbitnum
getwbitlen=picwbitlen/32*32
if picwbitlen\32!=0{
getwbitlen+32
}
bitmask=palcolnum-1
lineid=0
setid=0
repeat
if id>=imagedtsize:break
if getstwid<picwbitlen{
getlbyte=peek(imagedt,id):id++
repeat 8/pixelbitnum:ctid=cnt
if getstwid+ctid>=picwbitlen{
break
}
palid=(getlbyte>>(8-((ctid+1)*pixelbitnum)))&bitmask
poke vram,setid,palid
setid++
loop
}else{
id++
}
getstwid+=8
if getstwid>=getwbitlen{
lineid++
setid=setbitlen*lineid
getstwid=0
}
loop
bitmapflg=1
}else{ ;¥Õ¥ë¥«¥é¡¼
setbitlen=vramfxbitlenset(picwidth)
lineid=0
setid=0
dim coldt,masknum
colbytenum=pixelbitnum/8
if bitfieldflg{ ;¥Ó¥Ã¥È¥Õ¥£¡¼¥ë¥ÉÍ
chkbyte=0
repeat
if id>=imagedtsize:break
memcpy chkbyte,imagedt,colbytenum,0,id
id+=colbytenum
repeat masknum
coldt(cnt)=chkbyte&colmask(cnt)
if maskshiftdir(cnt){
coldt(cnt)<<maskshiftnum(cnt)
}else{
coldt(cnt)>>maskshiftnum(cnt)
}
loop
if setid+3>setbitlen*(lineid+1){
lineid++
setid=setbitlen*lineid
}
repeat 3
poke vram,setid,coldt(cnt):setid++
loop
loop
}else{ ;¥Ó¥Ã¥È¥Õ¥£¡¼¥ë¥É̵
repeat
if id>=imagedtsize:break
repeat colbytenum
if cnt<3{
coldt(cnt)=peek(imagedt,id):id++
}else{
id++
}
loop
if setid+3>setbitlen*(lineid+1){
lineid++
setid=setbitlen*lineid
}
repeat 3
poke vram,setid,coldt(cnt):setid++
loop
loop
}
bitmapflg=1
}
}
if bitmapflg=0{
picload filepath
}
return
#defcfunc vramfxbitlenset int m_gw
if (m_gw*3)\4!=0{
ix=4-((m_gw*3)\4)
}else{
ix=0
}
return 3*(m_gw+fx)+ix
#global
;»È¤¤Êý
buffer 1
bmppicload "²èÁü¥Ñ¥¹"
gsel 0
pos 0,0
gcopy 1,,,ginfo(12),ginfo(13)