File tree 3 files changed +50
-0
lines changed
3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ REBOL [
2
+ title: "REBOL 3 image codecs extensions"
3
+ name: 'codec-image-ext
4
+ author: "Oldes"
5
+ version: 0.1.0
6
+ date: 10-Nov-2020
7
+ history: [
8
+ 0.1.0 10-Nov-2020 "Oldes" {Extend native PNG codec with `size?` function}
9
+ ]
10
+ ]
11
+
12
+ if find codecs 'png [
13
+ extend codecs/png 'size2? func ["Return PNG image size or none" bin [binary! ]][
14
+ if all [
15
+ parse bin [
16
+ #{ 89504E470D0A1A0A } ;- PNG magic number
17
+ thru #{ 49484452 } ;- IHDR chunk
18
+ bin: to end
19
+ ]
20
+ 8 <= length? bin
21
+ ][
22
+ to pair! binary/read bin [UI32 UI32]
23
+ ]
24
+ ]
25
+ ]
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
Original file line number Diff line number Diff line change @@ -283,6 +283,14 @@ if find codecs 'JSON [
283
283
===end-group===
284
284
]
285
285
286
+ if find codecs 'PNG [
287
+ ===start-group=== "PNG codec"
288
+ --test-- "png/size?"
289
+ --assert 24x24 = codecs/png/size? read %units/files/r3.png
290
+ --assert none? codecs/png/size? read %units/files/test.aar
291
+ ===end-group===
292
+ ]
293
+
286
294
if find codecs 'XML [
287
295
===start-group=== "XML codec"
288
296
--test-- "XML decode test1"
Original file line number Diff line number Diff line change @@ -993,6 +993,7 @@ if product = 'view [
993
993
]
994
994
]
995
995
]
996
+ append mezz-files/3 %codec-image-ext.reb
996
997
997
998
foreach section [boot-base boot-sys boot-mezz] [
998
999
set section make block! 200
You can’t perform that action at this time.
0 commit comments