Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
CelestialAmber committed Jun 16, 2020
1 parent c294340 commit 4a8fdb6
Show file tree
Hide file tree
Showing 21 changed files with 1,869 additions and 795 deletions.
500 changes: 0 additions & 500 deletions PicReversing.c

This file was deleted.

42 changes: 18 additions & 24 deletions ShandalarImageToolbox/File Format Helpers/CATImageDecoder.cs
Expand Up @@ -18,42 +18,36 @@ public static Bitmap DecodeCatImage(ShandalarAsset asset)
int height = (int)BitConverter.ToUInt32(asset.data, 0x20);
int smallTableSize = (int)BitConverter.ToUInt32(asset.data, 0x24);

int var_14;
int var_24;
int newWidth;
int newHeight;

if ((int)BitConverter.ToUInt32(asset.data, 0) != 0)
{
/// var_14
int eax = width;
int ecx = (int)BitConverter.ToUInt32(asset.data, 0x28) - 1;
if (ecx == 0)
var_14 = eax / 2;
else
var_14 = eax;

/// var_24
eax = height;
ecx = (int)BitConverter.ToUInt32(asset.data, 0x28) - 1;
if (ecx == 0)
var_24 = eax / 2;
else
var_24 = eax;
bool halfSize = BitConverter.ToUInt32(asset.data, 0x28) == 1 ? true : false;
if (halfSize){
newWidth = width / 2;
newHeight = height / 2;
}
else{
newWidth = width;
newHeight = height;
}
}
else
{
var_14 = width;
var_24 = height;
newWidth = width;
newHeight = height;
}

int ptr1 = 0;
int ptr2 = ptr1 + width * width * 4 + 0x80;
int ptr3 = ptr2 + var_14 * var_14 * 4 + 0x80;
int ptr3 = ptr2 + newWidth * newWidth * 4 + 0x80;

int[] tempArray = GeneralUtilityFunctions.ByteArrayToIntArray(uncompressedData, 0);

Wavelet.WaveletDecode(ref tempArray, ptr1, width, smallTableSize);
Wavelet.WaveletDecode(ref tempArray, ptr2 / 4, var_14, smallTableSize);
Wavelet.WaveletDecode(ref tempArray, ptr3 / 4, var_14, smallTableSize);
Wavelet.WaveletDecode(ref tempArray, ptr2 / 4, newWidth, smallTableSize);
Wavelet.WaveletDecode(ref tempArray, ptr3 / 4, newWidth, smallTableSize);

/// YCbCr -> RGB
Bitmap outputImage = Wavelet.Decode_YCbCrToRGB(tempArray,
Expand All @@ -62,8 +56,8 @@ public static Bitmap DecodeCatImage(ShandalarAsset asset)
height,
ptr2 / 4,
ptr3 / 4,
var_14,
var_24);
newWidth,
newHeight);

// Return image
return outputImage;
Expand Down
16 changes: 8 additions & 8 deletions ShandalarImageToolbox/File Format Helpers/PicDecoder.cs
Expand Up @@ -91,7 +91,7 @@ private UInt16 GetWord()
private int onesCounter; /// Significant bit count
private UInt32 bitMask;
private byte[] LUT;
private int dword_5360E4; /// 0x100
private int DecodeTableIndex; /// 0x100
private int savedIndex = 0;
private byte savedByte = 0;

Expand Down Expand Up @@ -128,7 +128,7 @@ private void PrepareBuffer()
onesCounter = 9;
bitMask = 0x1FF;

dword_5360E4 = 0x100;
DecodeTableIndex = 0x100;

/// Fill FF FF 00 pattern

Expand Down Expand Up @@ -273,9 +273,9 @@ private byte NextRun ()
int oldIndex = (int)(b & bitMask);
int newIndex = oldIndex;

if (oldIndex >= dword_5360E4)
if (oldIndex >= DecodeTableIndex)
{
newIndex = dword_5360E4;
newIndex = DecodeTableIndex;
oldIndex = savedIndex;
PushValue(savedByte);
}
Expand All @@ -298,11 +298,11 @@ private byte NextRun ()

savedByte = GetLutValue(oldIndex);
PushValue(savedByte);
SetLutValue(dword_5360E4, savedByte);
SetLutIndex(dword_5360E4, savedIndex);
SetLutValue(DecodeTableIndex, savedByte);
SetLutIndex(DecodeTableIndex, savedIndex);

dword_5360E4++;
if (dword_5360E4 > bitMask)
DecodeTableIndex++;
if (DecodeTableIndex > bitMask)
{
onesCounter++;
bitMask = (bitMask << 1) | 1;
Expand Down
200 changes: 0 additions & 200 deletions ShandalarImageToolbox/FormMain.resx

This file was deleted.

0 comments on commit 4a8fdb6

Please sign in to comment.