Post by kevin on Jul 27, 2018 11:31:12 GMT -5
I DOWNLOADED THIS CODE FROM THE INTERNRT A FEW YEARS BACK
What it does is that you can load any image that you choes BUT it lods the image very big
Deos anyone know how I could resize or make the image smaller
What it does is that you can load any image that you choes BUT it lods the image very big
Deos anyone know how I could resize or make the image smaller
<span>nomainwin
WindowWidth = 300
WindowHeight = 300
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
graphicbox #main.g, -1, -1, 302, 302
open "Picture load" for window_nf as #main
print #main.g, "down; fill white; flush"
print #main, "font ms_sans_serif 10"
print #main, "trapclose [quit.main]"
open "gdiplus.dll" for dll as #gdip
filedialog "Choose an image","*.jpg;*.png;*.tiff;*.ico;*.bmp;*.gif",file$
if file$="" then
goto [quit.main]
else
hBmp=LoadImgFromFile(file$)
if hBmp<>0 then
loadbmp "pic",hBmp
print #main.g, "drawbmp pic 0 0;flush"
unloadbmp "pic"
'Because LB doesnt delete it for us
calldll #gdi32,"DeleteObject",hBmp as ulong, ret as ulong
else
notice "Could not load the image file!"
end if
end if
wait
[quit.main]
close #gdip
close #main
end
function wchar$(string$)
for i = 1 to len(string$)
wchar$=wchar$+mid$(string$,i,1)+chr$(0)
next i
wchar$=wchar$+chr$(0)+chr$(0)
end function
function LoadImgFromFile(file$)
struct dword,a as ulong
gdistart$=chr$(1)
for i = 1 to 15
gdistart$=gdistart$+chr$(0)
next i
calldll #gdip,"GdiplusStartup",dword as struct,gdistart$ as ptr,status as ulong
token=dword.a.struct
if status<>0 then
LoadImgFromFile=0
else
wFileLoc$=wchar$(file$)
calldll #gdip,"GdipCreateBitmapFromFile", _
wFileLoc$ as ptr,dword as struct,status as ulong
hPic=dword.a.struct
if status<>0 then
LoadImgFromFile=0
else
calldll #gdip,"GdipCreateHBITMAPFromBitmap", _
hPic as ulong,dword as struct,0 as ulong,status as ulong
hBmp=dword.a.struct
if status<>0 then
LoadImgFromFile=0
else
LoadImgFromFile=hBmp
end if
calldll #gdip,"GdipDisposeImage",hPic as ulong,ret as ulong
end if
calldll #gdip,"GdiplusShutdown",token as ulong,ret as ulong
end if
end function
</span>