You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It crashes on indexed images. I believe the issue lies here in Encode(Bitmap b, float quality, out IntPtr result, out long length)
using (Bitmap b2 = b.Clone(new Rectangle(0, 0, b.Width, b.Height), System.Drawing.Imaging.PixelFormat.Format32bppArgb))
{
Encode(b2, quality, out result, out length);
}
I've created a workaround that works nicely which is
if (b.PixelFormat.HasFlag(PixelFormat.Indexed))
{
using (var bitmap = new Bitmap(b.Width, b.Height, PixelFormat.Format32bppArgb))
{
using (var graphics = Graphics.FromImage(bitmap))
{
graphics.DrawImageUnscaled(b, 0, 0, b.Width, b.Height);
}
//this is using the stream to. it would have to be revised to reflect your out params
Encode(bitmap, to, quality);
}
}
The text was updated successfully, but these errors were encountered:
It crashes on indexed images. I believe the issue lies here in Encode(Bitmap b, float quality, out IntPtr result, out long length)
using (Bitmap b2 = b.Clone(new Rectangle(0, 0, b.Width, b.Height), System.Drawing.Imaging.PixelFormat.Format32bppArgb))
{
Encode(b2, quality, out result, out length);
}
I've created a workaround that works nicely which is
if (b.PixelFormat.HasFlag(PixelFormat.Indexed))
{
using (var bitmap = new Bitmap(b.Width, b.Height, PixelFormat.Format32bppArgb))
{
using (var graphics = Graphics.FromImage(bitmap))
{
graphics.DrawImageUnscaled(b, 0, 0, b.Width, b.Height);
}
//this is using the stream to. it would have to be revised to reflect your out params
Encode(bitmap, to, quality);
}
}
The text was updated successfully, but these errors were encountered: