Skip to content

Commit

Permalink
Fix depth not being included when exporting images
Browse files Browse the repository at this point in the history
  • Loading branch information
ds5678 committed Feb 19, 2024
1 parent d57951b commit 97bb6c2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Source/AssetRipper.Export.UnityProjects/Utils/DirectBitmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void SaveAsBmp(Stream stream)
GetDataAndComponentsForSaving(out byte[] data, out ColorComponents components);
lock (imageWriter)
{
imageWriter.WriteBmp(data, Width, Height, components, stream);
imageWriter.WriteBmp(data, Width, Height * Depth, components, stream);
}
}
}
Expand All @@ -159,7 +159,7 @@ public void SaveAsHdr(Stream stream)
GetDataAndComponentsForSaving(out byte[] data, out ColorComponents components);
lock (imageWriter)
{
imageWriter.WriteHdr(data, Width, Height, components, stream);
imageWriter.WriteHdr(data, Width, Height * Depth, components, stream);
}
}

Expand All @@ -174,7 +174,7 @@ public void SaveAsJpeg(Stream stream)
GetDataAndComponentsForSaving(out byte[] data, out ColorComponents components);
lock (imageWriter)
{
imageWriter.WriteJpg(data, Width, Height, components, stream, default);
imageWriter.WriteJpg(data, Width, Height * Depth, components, stream, default);
}
}
}
Expand All @@ -190,7 +190,7 @@ public void SaveAsPng(Stream stream)
GetDataAndComponentsForSaving(out byte[] data, out ColorComponents components);
lock (imageWriter)
{
imageWriter.WritePng(data, Width, Height, components, stream);
imageWriter.WritePng(data, Width, Height * Depth, components, stream);
}
}
}
Expand All @@ -200,7 +200,7 @@ public void SaveAsTga(Stream stream)
GetDataAndComponentsForSaving(out byte[] data, out ColorComponents components);
lock (imageWriter)
{
imageWriter.WriteTga(data, Width, Height, components, stream);
imageWriter.WriteTga(data, Width, Height * Depth, components, stream);
}
}

Expand All @@ -218,12 +218,12 @@ private void GetDataAndComponentsForSaving(out byte[] data, out ColorComponents
}
else if (TColor.HasAlphaChannel)
{
RgbConverter.Convert<TColor, TChannel, ColorRGBA<byte>, byte>(Bits, Width, Height, out data);
RgbConverter.Convert<TColor, TChannel, ColorRGBA<byte>, byte>(Bits, Width, Height * Depth, out data);
components = ColorComponents.RedGreenBlueAlpha;
}
else
{
RgbConverter.Convert<TColor, TChannel, ColorRGB<byte>, byte>(Bits, Width, Height, out data);
RgbConverter.Convert<TColor, TChannel, ColorRGB<byte>, byte>(Bits, Width, Height * Depth, out data);
components = ColorComponents.RedGreenBlue;
}
}
Expand Down Expand Up @@ -253,7 +253,7 @@ static void GetData(DirectBitmap<TColor, TChannel> @this, out byte[] data, out i
}
else
{
RgbConverter.Convert<TColor, TChannel, ColorBGRA32, byte>(@this.Bits, @this.Width, @this.Height, out data);
RgbConverter.Convert<TColor, TChannel, ColorBGRA32, byte>(@this.Bits, @this.Width, @this.Height * @this.Depth, out data);
pixelSize = 4;
pixelFormat = PixelFormat.Format32bppArgb;
}
Expand Down

0 comments on commit 97bb6c2

Please sign in to comment.