Skip to content

Commit

Permalink
Validated that QuickTime/GIF images works.
Browse files Browse the repository at this point in the history
Added support for QuickTime/MacPaint images.
  • Loading branch information
wiesmann committed Feb 29, 2024
1 parent 33abf86 commit 0d274c6
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
6 changes: 6 additions & 0 deletions QuickDrawViewer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -62,6 +64,7 @@
/* Begin PBXFileReference section */
E508C4F32B764CB2007686AE /* Planar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Planar.swift; sourceTree = "<group>"; };
E508C4F62B8E9575007686AE /* QuickDrawColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickDrawColor.swift; sourceTree = "<group>"; };
E508C4F92B911FD5007686AE /* MacPaint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacPaint.swift; sourceTree = "<group>"; };
E50ADB932B599BDE009EA7AF /* FixedPoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FixedPoint.swift; sourceTree = "<group>"; };
E553E4DB2B6AED62009B1EC2 /* Yuv2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Yuv2.swift; sourceTree = "<group>"; };
E553E4DE2B6FD9F5009B1EC2 /* QuickTime.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickTime.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down
24 changes: 24 additions & 0 deletions QuickDrawViewer/MacPaint.swift
Original file line number Diff line number Diff line change
@@ -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] = [];

}
1 change: 1 addition & 0 deletions QuickDrawViewer/QuickDrawColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions QuickDrawViewer/QuickTime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ func patchQuickTimeImage(quicktimeImage : inout QuickTimeIdsc) throws {
let skipped = data.subdata(in: 8..<data.count);
quicktimeImage.dataStatus = .patched;
quicktimeImage.data = skipped;
case "PNTG":
let macPaintImage = MacPaintImage();
try macPaintImage.load(data:data);
quicktimeImage.dataStatus = .decoded(decodedMetaData: macPaintImage);
quicktimeImage.data = Data(macPaintImage.bitmap);
default:
break;
}
Expand All @@ -311,6 +316,10 @@ func codecToContentType(qtImage : QuickTimeIdsc) -> 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)
}
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit 0d274c6

Please sign in to comment.