Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenJPEG 2.5.0 release #24

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/OpenJpegDotNet/IO/Reader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private static ulong Read(IntPtr buffer, ulong bytes, IntPtr userData)
unsafe
{
var buf = (Buffer*)userData;
var bytesToRead = (int)Math.Min((ulong)buf->Length, bytes);
var bytesToRead = (int)Math.Min((ulong)(buf->Length - buf->Position), bytes);
if (bytesToRead > 0)
{
NativeMethods.cstd_memcpy(buffer, IntPtr.Add(buf->Data, buf->Position), bytesToRead);
Expand Down Expand Up @@ -233,4 +233,4 @@ private void Dispose(bool disposing)

}

}
}
19 changes: 17 additions & 2 deletions src/OpenJpegDotNet/Util/ImageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static Image FromBitmap(Bitmap bitmap)
break;
case PixelFormat.Format8bppIndexed:
channels = 1;
colorSpace = ColorSpace.Srgb;
colorSpace = ColorSpace.Gray;
byteAllocated = 1;
break;
default:
Expand Down Expand Up @@ -189,7 +189,22 @@ public static Image FromBitmap(Bitmap bitmap)
{
for (var i = 0; i < channels; i++)
{
var target = image.Components[i].Data;
// need to fix the colorspace
IntPtr target;
if (channels >= 3) {
if (i == 0) {
target = image.Components[2].Data; // B-R
} else if (i == 1) {
target = image.Components[1].Data; // G-G
} else if (i == 2) {
target = image.Components[0].Data; // R-B
} else {
target = image.Components[i].Data;
}
} else {
target = image.Components[i].Data;
}

var pTarget = (int*)target;
var source = (byte*)scan0;
source += i;
Expand Down
2 changes: 1 addition & 1 deletion src/openjpeg
Submodule openjpeg updated 247 files