Skip to content

Commit

Permalink
PNG is most common
Browse files Browse the repository at this point in the history
  • Loading branch information
JrMasterModelBuilder committed Sep 24, 2023
1 parent 1cb1605 commit 651344f
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/icon/icns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import {IImageData} from '../types';
import {Icon} from '../icon';
import {concatUint8Arrays, packBitsIcns} from '../util';

const typeArgb = ['ic04', 'ic05'];

const typePng = [
'icp4',
'icp5',
Expand All @@ -18,6 +16,8 @@ const typePng = [
'ic14'
];

const typeArgb = ['ic04', 'ic05'];

const typeIcon24Bit = ['is32', 'il32', 'ih32', 'it32'];

const typeMask8Bit = ['s8mk', 'l8mk', 'h8mk', 't8mk'];
Expand Down Expand Up @@ -188,17 +188,17 @@ export class IconIcns extends Icon {
* @param type Type to encode as.
*/
protected _addFromRgbaType(imageData: Readonly<IImageData>, type: string) {
if (this._typeArgb.has(type)) {
if (this._typePng.has(type)) {
this.entries.push({
type,
data: this._encodeRgbaToTypeArgb(imageData, type)
data: this._encodeRgbaToTypePng(imageData, type)
});
return;
}
if (this._typePng.has(type)) {
if (this._typeArgb.has(type)) {
this.entries.push({
type,
data: this._encodeRgbaToTypePng(imageData, type)
data: this._encodeRgbaToTypeArgb(imageData, type)
});
return;
}
Expand All @@ -220,36 +220,36 @@ export class IconIcns extends Icon {
}

/**
* Encode RGBA image data to ARGB.
* Encode RGBA image data to PNG.
*
* @param imageData RGBA image data.
* @param _type Icon type.
* @returns Encoded data.
*/
protected _encodeRgbaToTypeArgb(
protected _encodeRgbaToTypePng(
imageData: Readonly<IImageData>,
_type: string
) {
// The compressed data always has an ARGB header.
return this._encodeRgbaToPackBits(
imageData,
true,
new Uint8Array([65, 82, 71, 66])
);
return this._encodeRgbaToPng(imageData);
}

/**
* Encode RGBA image data to PNG.
* Encode RGBA image data to ARGB.
*
* @param imageData RGBA image data.
* @param _type Icon type.
* @returns Encoded data.
*/
protected _encodeRgbaToTypePng(
protected _encodeRgbaToTypeArgb(
imageData: Readonly<IImageData>,
_type: string
) {
return this._encodeRgbaToPng(imageData);
// The compressed data always has an ARGB header.
return this._encodeRgbaToPackBits(
imageData,
true,
new Uint8Array([65, 82, 71, 66])
);
}

/**
Expand Down

0 comments on commit 651344f

Please sign in to comment.