Skip to content

Commit 7084263

Browse files
committed
Add Display P3 test for wide color gamut ICC profile embedding
- Add TestDisplayP3.png test image with Display P3 color space - Add testWebPEncodingDisplayP3 to verify wide color gamut support - Verify ICC profile embedding works correctly for Display P3 images (536 bytes) This test demonstrates that ICC profile embedding preserves wide color gamut information, preventing washed-out colors on Android and web browsers.
1 parent 8b7b680 commit 7084263

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

Tests/Images/TestDisplayP3.png

76.2 KB
Loading

Tests/SDWebImageWebPCoderTests.m

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,43 @@ - (void)testWebPEncodingEmbedICCProfile {
435435
WebPDemuxDelete(demuxer);
436436
}
437437

438+
- (void)testWebPEncodingDisplayP3 {
439+
// Test Display P3 wide color gamut encoding with ICC profile
440+
NSString *pngPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestDisplayP3" ofType:@"png"];
441+
if (!pngPath) {
442+
return;
443+
}
444+
445+
NSData *pngData = [NSData dataWithContentsOfFile:pngPath];
446+
UIImage *p3Image = [[UIImage alloc] initWithData:pngData];
447+
expect(p3Image).notTo.beNil();
448+
449+
NSData *webpData = [[SDImageWebPCoder sharedCoder] encodedDataWithImage:p3Image
450+
format:SDImageFormatWebP
451+
options:@{SDImageCoderEncodeCompressionQuality: @0.95}];
452+
expect(webpData).notTo.beNil();
453+
454+
// Check for ICCP chunk
455+
WebPData webp_data;
456+
WebPDataInit(&webp_data);
457+
webp_data.bytes = webpData.bytes;
458+
webp_data.size = webpData.length;
459+
460+
WebPDemuxer *demuxer = WebPDemux(&webp_data);
461+
expect(demuxer).notTo.beNil();
462+
463+
uint32_t flags = WebPDemuxGetI(demuxer, WEBP_FF_FORMAT_FLAGS);
464+
expect(flags & ICCP_FLAG).notTo.equal(0);
465+
466+
WebPChunkIterator chunk_iter;
467+
int result = WebPDemuxGetChunk(demuxer, "ICCP", 1, &chunk_iter);
468+
expect(result).notTo.equal(0);
469+
expect(chunk_iter.chunk.size).to.beGreaterThan(0);
470+
471+
WebPDemuxReleaseChunkIterator(&chunk_iter);
472+
WebPDemuxDelete(demuxer);
473+
}
474+
438475
@end
439476

440477
@implementation SDWebImageWebPCoderTests (Helpers)

0 commit comments

Comments
 (0)