-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathqtlib.ijs
More file actions
178 lines (166 loc) · 4.08 KB
/
qtlib.ijs
File metadata and controls
178 lines (166 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
NB.
require 'ide/qt/keys'
require 'ide/qt/gl2'
coclass 'jqtide'
NB. image
NB. Format Description Qt's support
NB. BMP Windows Bitmap Read/write
NB. GIF Graphic Interchange Format (optional) Read
NB. JPG Joint Photographic Experts Group Read/write
NB. JPEG Joint Photographic Experts Group Read/write
NB. PNG Portable Network Graphics Read/write
NB. PBM Portable Bitmap Read
NB. PGM Portable Graymap Read
NB. PPM Portable Pixmap Read/write
NB. TIFF Tagged Image File Format Read/write
NB. XBM X11 Bitmap Read/write
NB. XPM X11 Pixmap Read/write
RGBSEQ=: 1 NB. Qt
NB. =========================================================
NB. reading file images from memory to argb matrix
NB. y raw image data
getimg=: 3 : 0
if. WDCB_jqtide_ do.
try.
fliprgb^:(-.RGBSEQ) glgetimg_jgl2_ y
catch.
0 0$2-2
end.
else.
if. m [[ 'm wh'=. 0 3{ wdgetimg y;(#y);wh=. 2$2-2 do.
d=. _2 ic memr m,0,(*/wh,4),2
wdreadimg 2#<<0 NB. dispose temp image in qt side
(|.wh)$ fliprgb^:(-.RGBSEQ) d
else.
0 0$2-2
end.
end.
)
NB. =========================================================
NB. reading file images to argb matrix
NB. y image file name
readimg=: 3 : 0
if. WDCB_jqtide_ do.
try.
fliprgb^:(-.RGBSEQ) glreadimg_jgl2_ utf8 ,y
catch.
0 0$2-2
end.
else.
if. m [[ 'm wh'=. 0 2{ wdreadimg (utf8 ,y);wh=. 2$2-2 do.
d=. _2 ic memr m,0,(*/wh,4),2
wdreadimg 2#<<0 NB. dispose temp image in qt side
(|.wh)$ fliprgb^:(-.RGBSEQ) d
else.
0 0$2-2
end.
end.
)
NB. =========================================================
NB. write image data to memory
NB. x rgb matrix
NB. y 'jpeg|png|ico|bmp' [ ; 'quality' ; '[0,100]|_1' ]
putimg=: 4 : 0
if3=. (3=#$x) *. 3={:$x
if. if3 do.
x=. setalpha 256&#. x
end.
'h w'=. $x
d=. ,x
type=. 'jpeg'
opt=. ''
quality=. _1
if. 1= #y=. boxxopen y do.
type=. >@{.y
elseif. 2< #y do.
type=. >@{.y
opt=. 2{.}.y
end.
if. 'jpg'-:type do. type=. 'jpeg'
elseif. 'tif'-:type do. type=. 'tiff'
end.
type=. toupper type
if. 'quality'-:>@{.opt do. quality=. <. >@{:opt end.
d=. fliprgb^:(-.RGBSEQ) d
if. WDCB_jqtide_ do.
try.
glputimg_jgl2_ ((h,w)$d);type;quality
catch.
''
end.
else.
'm len'=. 0 3{ wdputimg (2 ic d); (w,h); (len=. ,_1); type; quality
if. m do.
z=. memr m,0,len,2
wdputimg (4#(<<0)),<0 NB. dispose temp bytearry in qt side
z
else.
''
end.
end.
)
NB. =========================================================
NB. write image data to file
NB. x rgb matrix
NB. y filename [ ; 'jpeg|png|ico|bmp' [ ; 'quality' ; [0,100]|_1 ]]
writeimg=: 4 : 0
if3=. (3=#$x) *. 3={:$x
if. if3 do.
x=. setalpha 256&#. x
end.
'h w'=. $x
d=. ,x
y=. boxopen y
f=. > fboxname {. y
type=. 'jpeg'
opt=. ''
quality=. _1
if. 1= #y do.
type=. }. (}.~ i:&'.') f
else.
type=. >1{y
opt=. 2{.2}.y
end.
type=. tolower type
if. 'jpg'-:type do. type=. 'jpeg'
elseif. 'tif'-:type do. type=. 'tiff'
end.
type=. toupper type
if. 'quality'-:>@{.opt do. quality=. <. >@{:opt end.
d=. fliprgb^:(-.RGBSEQ) d
if. WDCB_jqtide_ do.
try.
glwriteimg_jgl2_ ((h,w)$d);f;type;quality
catch.
end.
else.
wdwriteimg (2 ic d); (w,h); f; type; quality
end.
EMPTY
)
NB.
cocurrent IFQT{'jqtide';'z'
NB. =========================================================
wdreadimg=: ('"',libjqt,'" wdreadimg ',(IFWIN#'+'),' x *c *i')&cd
wdgetimg=: ('"',libjqt,'" wdgetimg ',(IFWIN#'+'),' x *c i *i')&cd
wdwriteimg=: ('"',libjqt,'" wdwriteimg ',(IFWIN#'+'),' i *c *i *c *c i')&cd
wdputimg=: ('"',libjqt,'" wdputimg ',(IFWIN#'+'),' x *c *i *i *c i')&cd
NB. =========================================================
NB. preserved for compatibility
getsha1=: 3 : 0
gethash 'sha1';y
)
NB. =========================================================
gethash=: 3 : 0
't m'=. y
t gethash m
:
m=. ,y
c=. '"',libjqt,'" gethash ',(IFWIN#'+'),' i *c *c i * *i'
'r t m w p n'=. c cd (tolower x);m;(#m);(,2);,0
res=. memr p,0,n
if. r do.
res (13!:8) 3
end.
res
)