Solution for "A Graphics Object cannot be Created from an Image that has an Indexed Pixel Format"


错误信息

Solution for "A Graphics Object cannot be Created from an Image that has an Indexed Pixel Format"

Solution for "A Graphics Object cannot be Created from an Image that has an Indexed Pixel Format"

排查问题

  名称 类型
  img.PixelFormat Format8bppIndexed System.Drawing.Imaging.PixelFormat

当您访问/编辑以下类型的图像时,我们将收到错误“无法从具有索引像素格式的图像创建图形对象”

  • PixelFormatUndefined
  • PixelFormatDontCare
  • PixelFormat1bppIndexed
  • PixelFormat4bppIndexed
  • PixelFormat8bppIndexed
  • PixelFormat16bppGrayScale
  • PixelFormat16bppARGB1555

解决方案

转换img为bitmap

C# 全选
Bitmap img = new Bitmap(new Bitmap( imag ));

Solution for "A Graphics Object cannot be Created from an Image that has an Indexed Pixel Format"

C# 全选
try
{
    // create Image Object using rear image byte[]
    Image imag = Image.FromStream(new MemoryStream(imageR));
    // Derive BitMap object using Image instance, so that you can avoid the issue
    //"a graphics object cannot be created from an image that has an indexed pixel format"
    Bitmap img = new Bitmap(new Bitmap( imag ));
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}
版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
管理员
上一篇:VS2010到VS2022各个版本的密钥
下一篇:html版权符号怎么打出来
评论列表

发表评论

评论内容
昵称:
关联文章

Solution for "A Graphics Object cannot be Created from an Image that has an Indexed Pixel Format"
Cannot resolve scoped service from root provider ASP.NET Core
EF生成迁移脚本报错:Entity type '' has a split mapping, but it doesn't map any non-primary key property to the main store object. Keep at least one non-primary key property mapped to a column on '.
web前端格式化缩进Razor代码,razor format
.net Core Swagger报错 the same schemaid is already used for type swagger
C# Graphics给图片添加水印
C# Graphics画有填充和无填充的形状
TinyMCE
SqlSugar Image字段BUG
C#多线程下载图片 URL转Image
明细页保存后刷新A页面数据
sql server系统表详细说明 之 sys.objects
sql server系统表详细说明 之 sys.system_objects
sql server系统表详细说明 之 sys.all_objects
Macros $(DevEnvDir), $(SolutionFileName), $(SolutionPath), $(SolutionDir), $(SolutionName), $(SolutionExt) are not defined during publish. Worked fine during build
.NET Core中使用编码GB2312报错‘GB2312‘ is not a supported encoding name 解决方案
VUE使用sass提示在sass文件中提示Syntax Error : this.getOptions is not a function
C# Winform选择文件夹目录
如何关掉has been registered with the fake serial number> 弹窗
.NET Core 运行时T4模板使用,T4生成代码

联系我们
联系电话:15090125178(微信同号)
电子邮箱:garson_zhang@163.com
站长微信二维码
微信二维码