From 0d274c6e5f3b5f4a81e9445381bdfe7f99e34066 Mon Sep 17 00:00:00 2001 From: Matthias Wiesmann Date: Thu, 29 Feb 2024 21:53:38 +0100 Subject: [PATCH] Validated that QuickTime/GIF images works. Added support for QuickTime/MacPaint images. --- QuickDrawViewer.xcodeproj/project.pbxproj | 6 ++++++ QuickDrawViewer/MacPaint.swift | 24 +++++++++++++++++++++++ QuickDrawViewer/QuickDrawColor.swift | 1 + QuickDrawViewer/QuickTime.swift | 9 +++++++++ README.md | 4 +++- 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 QuickDrawViewer/MacPaint.swift diff --git a/QuickDrawViewer.xcodeproj/project.pbxproj b/QuickDrawViewer.xcodeproj/project.pbxproj index 9ebc107..5ed7174 100644 --- a/QuickDrawViewer.xcodeproj/project.pbxproj +++ b/QuickDrawViewer.xcodeproj/project.pbxproj @@ -11,6 +11,8 @@ E508C4F52B764CB2007686AE /* Planar.swift in Sources */ = {isa = PBXBuildFile; fileRef = E508C4F32B764CB2007686AE /* Planar.swift */; }; E508C4F72B8E9575007686AE /* QuickDrawColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E508C4F62B8E9575007686AE /* QuickDrawColor.swift */; }; E508C4F82B8E9575007686AE /* QuickDrawColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E508C4F62B8E9575007686AE /* QuickDrawColor.swift */; }; + E508C4FA2B911FD5007686AE /* MacPaint.swift in Sources */ = {isa = PBXBuildFile; fileRef = E508C4F92B911FD5007686AE /* MacPaint.swift */; }; + E508C4FB2B911FD5007686AE /* MacPaint.swift in Sources */ = {isa = PBXBuildFile; fileRef = E508C4F92B911FD5007686AE /* MacPaint.swift */; }; E50ADB942B599BDE009EA7AF /* FixedPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = E50ADB932B599BDE009EA7AF /* FixedPoint.swift */; }; E50ADB952B599BDE009EA7AF /* FixedPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = E50ADB932B599BDE009EA7AF /* FixedPoint.swift */; }; E50ADB972B599CDE009EA7AF /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E59CDF6F2B42C0E500D7BB7B /* ContentView.swift */; }; @@ -62,6 +64,7 @@ /* Begin PBXFileReference section */ E508C4F32B764CB2007686AE /* Planar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Planar.swift; sourceTree = ""; }; E508C4F62B8E9575007686AE /* QuickDrawColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickDrawColor.swift; sourceTree = ""; }; + E508C4F92B911FD5007686AE /* MacPaint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacPaint.swift; sourceTree = ""; }; E50ADB932B599BDE009EA7AF /* FixedPoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FixedPoint.swift; sourceTree = ""; }; E553E4DB2B6AED62009B1EC2 /* Yuv2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Yuv2.swift; sourceTree = ""; }; E553E4DE2B6FD9F5009B1EC2 /* QuickTime.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickTime.swift; sourceTree = ""; }; @@ -157,6 +160,7 @@ E55E05F62B61A74A00EA1AD8 /* RoadPizza.swift */, E508C4F32B764CB2007686AE /* Planar.swift */, E553E4DB2B6AED62009B1EC2 /* Yuv2.swift */, + E508C4F92B911FD5007686AE /* MacPaint.swift */, E59CDF712B42C0E600D7BB7B /* Assets.xcassets */, E59CDF762B42C0E600D7BB7B /* Info.plist */, E59CDF772B42C0E600D7BB7B /* QuickDrawViewer.entitlements */, @@ -290,6 +294,7 @@ E5CDA02D2B4450FB008DC6D6 /* ImageWrapper.swift in Sources */, E59CDF6E2B42C0E500D7BB7B /* QuickDrawViewerDocument.swift in Sources */, E553E4E22B6FFA53009B1EC2 /* TypeCode.swift in Sources */, + E508C4FA2B911FD5007686AE /* MacPaint.swift in Sources */, E59CDFB32B42EE0A00D7BB7B /* QuickDrawTypes.swift in Sources */, E50ADB942B599BDE009EA7AF /* FixedPoint.swift in Sources */, E59CDFB52B42EE0A00D7BB7B /* QuickDrawRender.swift in Sources */, @@ -322,6 +327,7 @@ E5CDA02E2B4450FB008DC6D6 /* ImageWrapper.swift in Sources */, E59CDFB62B42EE0A00D7BB7B /* QuickDrawRender.swift in Sources */, E59CDFB22B42EE0A00D7BB7B /* QuickDrawReader.swift in Sources */, + E508C4FB2B911FD5007686AE /* MacPaint.swift in Sources */, E5CDA0282B44155E008DC6D6 /* QuickDrawParser.swift in Sources */, E59CDFAE2B42EE0A00D7BB7B /* QuickDrawOpcodes.swift in Sources */, E55E05F82B61A74A00EA1AD8 /* RoadPizza.swift in Sources */, diff --git a/QuickDrawViewer/MacPaint.swift b/QuickDrawViewer/MacPaint.swift new file mode 100644 index 0000000..e7aa2fa --- /dev/null +++ b/QuickDrawViewer/MacPaint.swift @@ -0,0 +1,24 @@ +// +// MacPaint.swift +// QuickDrawViewer +// +// Created by Matthias Wiesmann on 29.02.2024. +// + +import Foundation + +// MacPaint images are fixed size (720 × 576) PackBit compressed bitmaps. +class MacPaintImage : PixMapMetadata { + + func load(data : Data) throws { + self.bitmap = try DecompressPackBit(data: Array(data), unpackedSize: 720 * 72); + } + + let rowBytes: Int = 72; // 576 ÷ 8 + var cmpSize: Int = 1; + var pixelSize: Int = 1; + let dimensions = QDDelta(dv: FixedPoint(720), dh: FixedPoint(576)); + var clut: QDColorTable? = QDColorTable.whiteBlack; + var bitmap: [UInt8] = []; + +} diff --git a/QuickDrawViewer/QuickDrawColor.swift b/QuickDrawViewer/QuickDrawColor.swift index abf1e1f..9bce878 100644 --- a/QuickDrawViewer/QuickDrawColor.swift +++ b/QuickDrawViewer/QuickDrawColor.swift @@ -106,6 +106,7 @@ class QDColorTable : CustomStringConvertible { var id : Int = 0; static let blackWhite : QDColorTable = QDColorTable(clut:[QDColor.black, QDColor.white]); + static let whiteBlack : QDColorTable = QDColorTable(clut:[QDColor.white, QDColor.black]); static func forClutId(clutId: Int) -> QDColorTable? { if (clutId == 8) { diff --git a/QuickDrawViewer/QuickTime.swift b/QuickDrawViewer/QuickTime.swift index 911cec4..4139c38 100644 --- a/QuickDrawViewer/QuickTime.swift +++ b/QuickDrawViewer/QuickTime.swift @@ -295,6 +295,11 @@ func patchQuickTimeImage(quicktimeImage : inout QuickTimeIdsc) throws { let skipped = data.subdata(in: 8.. String { return "com.truevision.tga-image"; case "mjp2": return "public.jpeg-2000"; + case "WRLE": + return "com.microsoft.bmp"; + case "PNTG": + return "com.apple.macpaint-image"; default: return "public." + qtImage.codecType.description.trimmingCharacters(in: .whitespacesAndNewlines) } diff --git a/README.md b/README.md index 87ddb40..54c7977 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,10 @@ It supports the following features. * Palette images * Direct (RGB) images * QuickTime embedded images with the following codecs: - * External image formats: JPEG, TIFF, PNG, BMP, JPEG-2000. + * External image formats: JPEG, TIFF, PNG, BMP, JPEG-2000, GIF + (these are handled natively by the renderer). * RAW (`raw `). + * MacPaint * Apple Video (`RPZA`), Apple Component Video (`YUV2`). * Planar Video (`8BPS`). * QuickTime images which use a supported codec (see above).