SQLite format 3 @ -
QM2 -
q {tabletextstextsCREATE TABLE texts(id INTEGER PRIMARY KEY REFERENCES items(id) ON DELETE CASCADE ON UPDATE CASCADE,date BLOB,text TEXT)wtableitemsitemsCREATE TABLE items(id INTEGER PRIMARY KEY,pid INT,ord BLOB,flags INT,name TEXT,[trigger] TEXT,icon TEXT,td,guid BLOB)
R#]'f6 +
! ,
FI_OnError`rOc*
,
FiBitmap.P)HAg.͡r,,
# ,
FreeImage.hH\BBI[jD.
' ,
ref_FreeImage_LO+-&
,
private'e?z>Okе
4
5 , FI_ShowMoreErrorInfo9yLY>s-
' , FiBitmap.DrawADW2
1 ,
FiBitmap.ToHBITMAPkFBg4
5 , FiBitmap.FromHBITMAPdMk3
/
+ , FiBitmap.DeleteOC,9L/
+ , FiBitmap.Attachur7N&rt-80
- , FiBitmap.SaveMem;wJ#k40
- , FiBitmap.LoadMem0,PqDԱ]-
' , FiBitmap.SavenĆ=@Nwo-
' , FiBitmap.LoadFXz+
# , __FreeImage[LAI
-
' , FiBitmap help2 UJv7hd!
, file - ,
- resize, etc. Unlike many other graphics libraries like ImageMagick, you need just single dll file (~3MB), don't need to install. Easy to use, well documented.
Other alternatives that can be easily used in QM: GDI+ (a Windows component), GflAx (a COM component, seems abandoned). Search forum.
Class FiBitmap stores and manages FIBITMAP*. Auto-deletes when destroying the variable.
The class wraps just basic FreeImage API functions - load, save, etc.
All FreeImage API functions etc can be accessed through FIMG, like FIMG.FreeImage_GetWidth(x) or FIMG.FIF_BMP.
A FiBitmap variable can be used with FreeImage API functions as FIBITMAP*.
EXAMPLES
#compile "__FreeImage" ;;declares FIMG and FiBitmap. You can put this line in your init2 function, or in macros where used.
FI_ShowMoreErrorInfo ;;optional
FiBitmap x
str test=
1 convert file format bmp to png
2 capture image from screen and save as png file
3 load png file and store the bitmap in clipboard
4 load png file and draw in a window
5 resize to 50%
6 load/save from/to memory
7 load from resources (QM 2.4.1+)
sel ShowMenu(test)
case 1 ;;convert file format bmp to png
x.Load(FIMG.FIF_BMP "$my qm$\test.bmp")
x.Save(FIMG.FIF_PNG "$my qm$\test-conv.png")
case 2 ;;capture image from screen and save as png file
__GdiHandle hb
if(!CaptureImageOrColor(hb 0)) ret
x.FromHBITMAP(hb)
x.Save(FIMG.FIF_PNG "$my qm$\test-capt.png")
case 3 ;;load png file and store the bitmap in clipboard
x.Load(FIMG.FIF_PNG "$my qm$\test-conv.png")
__GdiHandle hb2=x.ToHBITMAP ;;no, don't need to delete bitmap stored in clipboard
int hb2=x.ToHBITMAP
OpenClipboard 0; EmptyClipboard
SetClipboardData CF_BITMAP hb2
CloseClipboard
case 4 ;;load png file and draw in a window
x.Load(FIMG.FIF_PNG "$my qm$\test-conv.png")
int hwnd=0 ;;screen. Normally you would draw in a window/dialog procedure on WM_PAINT, and use BeginPoint/EndPaint instead of GetDC/ReleaseDC.
RECT r; SetRect &r 0 0 FIMG.FreeImage_GetWidth(x) FIMG .FreeImage_GetHeight(x)
int hdc=GetDC(hwnd)
x.Draw(hdc r)
ReleaseDC hwnd hdc
case 5 ;;resize to 50%
x.Load(FIMG.FIF_BMP "$my qm$\test.bmp")
int newWidth=FIMG.FreeImage_GetWidth(x)/2
int newHeight=FIMG.FreeImage_GetHeight(x)/2
FiBitmap x2.Attach(FIMG.FreeImage_Rescale(x newWidth newHeight FIMG.FILTER_BSPLINE))
x2.Save(FIMG.FIF_BMP "$my qm$\test-siz.bmp")
case 6 ;;load/save from/to memory
str s1 s2
s1.getfile("$my qm$\test.bmp")
x.LoadMem(FIMG.FIF_BMP s1)
x.SaveMem(FIMG.FIF_JPEG s2)
s2.setfile("$my qm$\test-mem.jpg")
#if QMVER>=0x02040100
case 7 ;;load from resources
s1.getfile("$my qm$\test.bmp")
_qmfile.ResourceAdd(+-1 "test FiBitmap.bmp" s1 s1.len) ;;add a bitmap resource for testing
x.Load(FIMG.FIF_BMP "resource:test FiBitmap.bmp")
s1.encrypt(32); _qmfile.ResourceAdd(+-1 "image:test FiBitmap" s1 s1.len) ;;add a compressed .bitmap resource for testing
x.Load(FIMG.FIF_BMP "image:test FiBitmap")
x.Save(FIMG.FIF_PNG "$my qm$\test-res.png")
#endif
Y > Y b 7C7
function fif_type $file_ [flags]
Loads image file or resource, and sets this variable to manage the FIBITMAP object (auto-delete etc).
Calls FreeImage_Load. Passes fif_type and flags unchanged.
Error if failed.
sel file_ 2
case ["resource:*","image:*"]
_s.getfile(file_)
if(file_[0]='i') _s.decrypt(32)
ret LoadMem(fif_type _s flags)
err+ end _error
Delete
b=FIMG.FreeImage_LoadU(fif_type @_s.expandpath(file_) flags)
if(!b) end ERR_FAILED
I C-nref FIMG "ref_FreeImage" 1
class FiBitmap FIMG.FIBITMAP*b
V C7q FreeImage API declarations, and class FiBitmap.
FreeImage is a graphics library, http://freeimage.sourceforge.net/download.html
Download FreeImage DLL and Documentation. Don't need source. Put FreeImage.dll in QM folder.
FreeImage is good for converting image file formats and basic image manipulation with good quality
B$|4function fif_type str&mem [flags]
Loads image file data from memory (str variable) and sets this variable to manage the FIBITMAP object.
Calls FreeImage_LoadFromMemory. Passes fif_type and flags unchanged.
Error if failed.
REMARKS
To load from macro resources, you can use Load instaed.
Delete
if(!mem.len) end ERR_BADARG
int m=FIMG.FreeImage_OpenMemory(mem mem.len)
if(!m) end ERR_FAILED
b=FIMG.FreeImage_LoadFromMemory(fif_type +m flags)
FIMG.FreeImage_CloseMemory(+m)
if(!b) end ERR_FAILED
n OB
a]function fif_type $file_ [flags]
Saves to image file.
Calls FreeImage_Save. Passes fif_type and flags unchanged.
Error if failed.
if(!FIMG.FreeImage_SaveU(fif_type b @_s.expandpath(file_) flags)) end ERR_FAILED
\ : \ ' ABq76
Calls FreeImage_Unload and sets this variable empty.
Call if want to free memory before the variable dies.
if(b) FIMG.FreeImage_Unload(b); b=0
1 UB