mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-27 13:54:44 +00:00
Rename RenderBase.OTextureFormat.rgba8 to RenderBase.OTextureFormat.argb8
This commit is contained in:
@@ -1525,7 +1525,7 @@ namespace Ohana3DS_Rebirth.Ohana
|
||||
/// </summary>
|
||||
public enum OTextureFormat
|
||||
{
|
||||
rgba8 = 0,
|
||||
argb8 = 0,
|
||||
rgb8 = 1,
|
||||
rgba5551 = 2,
|
||||
rgb565 = 3,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Drawing;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ohana3DS_Rebirth.Ohana
|
||||
{
|
||||
@@ -20,12 +21,12 @@ namespace Ohana3DS_Rebirth.Ohana
|
||||
public static Bitmap Decode(byte[] data, int width, int height, RenderBase.OTextureFormat format)
|
||||
{
|
||||
byte[] output = new byte[width * height * 4];
|
||||
long dataOffset = 0;
|
||||
int dataOffset = 0;
|
||||
bool toggle = false;
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case RenderBase.OTextureFormat.rgba8:
|
||||
case RenderBase.OTextureFormat.argb8:
|
||||
for (int tY = 0; tY < height / 8; tY++)
|
||||
{
|
||||
for (int tX = 0; tX < width / 8; tX++)
|
||||
@@ -34,11 +35,10 @@ namespace Ohana3DS_Rebirth.Ohana
|
||||
{
|
||||
int x = tileOrder[pixel] % 8;
|
||||
int y = (tileOrder[pixel] - x) / 8;
|
||||
long outputOffset = ((tX * 8) + x + ((tY * 8 + y) * width)) * 4;
|
||||
int outputOffset = ((tX * 8 + x) + ((tY * 8 + y) * width)) * 4;
|
||||
|
||||
Buffer.BlockCopy(data, (int)dataOffset + 1, output, (int)outputOffset, 3);
|
||||
Buffer.BlockCopy(data, dataOffset + 1, output, outputOffset, 3);
|
||||
output[outputOffset + 3] = data[dataOffset];
|
||||
|
||||
dataOffset += 4;
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ namespace Ohana3DS_Rebirth.Ohana
|
||||
int y = (tileOrder[pixel] - x) / 8;
|
||||
long outputOffset = ((tX * 8) + x + ((tY * 8 + y) * width)) * 4;
|
||||
|
||||
Buffer.BlockCopy(data, (int)dataOffset, output, (int)outputOffset, 3);
|
||||
Buffer.BlockCopy(data, dataOffset, output, (int)outputOffset, 3);
|
||||
output[outputOffset + 3] = 0xff;
|
||||
|
||||
dataOffset += 3;
|
||||
@@ -327,7 +327,7 @@ namespace Ohana3DS_Rebirth.Ohana
|
||||
int outputOffset = 0;
|
||||
switch (format)
|
||||
{
|
||||
case RenderBase.OTextureFormat.rgba8:
|
||||
case RenderBase.OTextureFormat.argb8:
|
||||
for (int tY = 0; tY < img.Height / 8; tY++)
|
||||
{
|
||||
for (int tX = 0; tX < img.Width / 8; tX++)
|
||||
@@ -340,14 +340,13 @@ namespace Ohana3DS_Rebirth.Ohana
|
||||
|
||||
Buffer.BlockCopy(data, dataOffset, output, outputOffset + 1, 3);
|
||||
output[outputOffset] = data[dataOffset + 3];
|
||||
|
||||
outputOffset += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default: throw new NotImplementedException();
|
||||
default: throw new NotImplementedException(nameof(format));
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace PckStudio.Classes.Utils
|
||||
{
|
||||
switch (fmt)
|
||||
{
|
||||
case RenderBase.OTextureFormat.rgba8:
|
||||
case RenderBase.OTextureFormat.argb8:
|
||||
return w * h * 4;
|
||||
case RenderBase.OTextureFormat.rgb8:
|
||||
return w * h * 3;
|
||||
@@ -66,11 +66,11 @@ namespace PckStudio.Classes.Utils
|
||||
{
|
||||
if (ReadString(stream, 4) == "3DST")
|
||||
{
|
||||
int offset = 32;
|
||||
const int offset = 32;
|
||||
stream.Seek(8L, SeekOrigin.Begin);
|
||||
RenderBase.OTextureFormat format = ReadInt32(stream) switch
|
||||
{
|
||||
0 => RenderBase.OTextureFormat.rgba8,
|
||||
0 => RenderBase.OTextureFormat.argb8,
|
||||
1 => RenderBase.OTextureFormat.rgb8,
|
||||
2 => RenderBase.OTextureFormat.rgba5551,
|
||||
3 => RenderBase.OTextureFormat.rgb8,
|
||||
@@ -91,7 +91,7 @@ namespace PckStudio.Classes.Utils
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void SetImageTo3DST(Stream stream, Image source, RenderBase.OTextureFormat format = RenderBase.OTextureFormat.rgba8)
|
||||
public static void SetImageTo3DST(Stream stream, Image source, RenderBase.OTextureFormat format = RenderBase.OTextureFormat.argb8)
|
||||
{
|
||||
// TODO: fix Encoding
|
||||
WriteString(stream, "3DST"); // 0
|
||||
@@ -102,7 +102,6 @@ namespace PckStudio.Classes.Utils
|
||||
WriteInt32(stream, 0); // 20
|
||||
WriteInt32(stream, 0); // 24
|
||||
WriteInt32(stream, 0); // 28
|
||||
WriteInt32(stream, 0); // 32
|
||||
source.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
byte[] buffer = TextureCodec.Encode(new Bitmap(source), format);
|
||||
stream.Write(buffer, 0, buffer.Length);
|
||||
|
||||
Reference in New Issue
Block a user