Skip to content

Commit

Permalink
Don't ABGR swizzle in J2KImage
Browse files Browse the repository at this point in the history
  • Loading branch information
cinderblocks committed Aug 10, 2024
1 parent 71c5511 commit 7890abf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions CSJ2K.Skia/J2kImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,16 +278,20 @@ public static PortableImage FromStream(Stream stream, ParameterList parameters =
case 1:
rowvalues[offset + 0] = tmp[0];
break;
case 2:
rowvalues[offset + 0] = tmp[0];
rowvalues[offset + 1] = tmp[1];
break;
case 3:
rowvalues[offset + 0] = tmp[2];
rowvalues[offset + 0] = tmp[0];
rowvalues[offset + 1] = tmp[1];
rowvalues[offset + 2] = tmp[0];
rowvalues[offset + 2] = tmp[2];
break;
case 4:
rowvalues[offset + 0] = tmp[3];
rowvalues[offset + 1] = tmp[2];
rowvalues[offset + 2] = tmp[1];
rowvalues[offset + 3] = tmp[0];
rowvalues[offset + 0] = tmp[0];
rowvalues[offset + 1] = tmp[1];
rowvalues[offset + 2] = tmp[2];
rowvalues[offset + 3] = tmp[3];
break;
default:
throw new InvalidOperationException($"Invalid number of components: {numComps}");
Expand Down
2 changes: 1 addition & 1 deletion CSJ2K.Skia/Util/SKBitmapImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected override object GetImageObject()
var bitmap = new SKBitmap();

var gcHandle = GCHandle.Alloc(Bytes, GCHandleType.Pinned);
var info = new SKImageInfo(Width, Height, SKColorType.Bgra8888, SKAlphaType.Unpremul);
var info = new SKImageInfo(Width, Height, SKColorType.Rgba8888, SKAlphaType.Unpremul);
bitmap.InstallPixels(info, gcHandle.AddrOfPinnedObject(), info.RowBytes,
delegate { gcHandle.Free(); }, null);

Expand Down

0 comments on commit 7890abf

Please sign in to comment.