Skip to content

Commit f8f5510

Browse files
committed
FEAT: enable loading exact frame from an image on macOS
1 parent 972dcc0 commit f8f5510

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

src/core/n-image.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ typedef struct REBCLR {
364364
*/ REBNATIVE(image)
365365
/*
366366
// image: native [
367-
// "Interface to basic image encoding/decoding (only on Windows so far!)"
367+
// "Interface to basic image encoding/decoding (only on Windows and macOS so far!)"
368368
// /load "Image file to load or binary to decode"
369369
// src-file [file! binary!]
370370
// /save "Encodes image to file or binary"

src/os/osx/sys-codecs.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ int DecodeImageFromFile(const char *uri, unsigned int frame, REBCDI *codi)
7373
binSrc = CFDataCreateWithBytesNoCopy(NULL, codi->data, codi->len, NULL);
7474
imgSrc = CGImageSourceCreateWithData(binSrc, 0);
7575
}
76-
img = CGImageSourceCreateImageAtIndex(imgSrc, 0, 0);
76+
img = CGImageSourceCreateImageAtIndex(imgSrc, frame, 0);
7777
ASSERT_NOT_NULL(img, 3, "create an image");
7878
w = CGImageGetWidth(img);
7979
h = CGImageGetHeight(img);

src/tests/units/codecs-test.r3

+10
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,16 @@ if find codecs 'GIF [
549549
img/rgb = #{C800000000C800C800FFFFFF}
550550
]
551551
try [delete %new.gif]
552+
553+
--test-- "animated gif"
554+
--assert try [all [
555+
i1: image/load/frame %units/files/animation.gif 1
556+
i2: image/load/frame %units/files/animation.gif 2
557+
i3: image/load/frame %units/files/animation.gif 3
558+
#{4D99990699791F57F238C7195ABB0DE7} == checksum i1/rgba 'md5
559+
#{878BACEFB949C6435702F87D5B62F9FA} == checksum i2/rgba 'md5
560+
#{1414A649C4CF2E2D9DE3A8502A4425AA} == checksum i3/rgba 'md5
561+
]]
552562
===end-group===
553563
]
554564

src/tests/units/files/animation.gif

218 Bytes
Loading

0 commit comments

Comments
 (0)