当前位置:网站首页>Graphics. Fromimage reports an error "graphics object cannot be created from an image that has an indexed pixel..."
Graphics. Fromimage reports an error "graphics object cannot be created from an image that has an indexed pixel..."
2022-04-23 05:19:00 【gc_ two thousand two hundred and ninety-nine】
test OCR modular PaddleSharp In the process , In order to draw a rectangle containing text blocks in the picture , use Graphics.FromImage Function to get the drawing object of the picture . When testing with the pictures in the previous article ,jpg Pictures can be drawn normally , But test references 1 in png Format of ID card picture , The program reported the following error :
A Graphics object cannot be created from an image that has an indexed pixel format. (Parameter ‘image’)
from MSDN see , call Graphics.FromImage Exception in function , An exception will be thrown when the picture has index pixel format or the format is not defined , The errors encountered in this article refer to indexed pixel Index pixel , Therefore, it should be that the tested image format does not support Graphics.FromImage.

reference 3 This paper introduces the index pixel format picture , Its common format is gif and png, The main purpose is to reduce the picture size . reference 4 Index pixel format image creation is given in Graphics Common handling of objects , Copy the picture to another Bitmap Object before using Graphics.
For the question of this article , There are two ways , One is to program png Convert the picture to bmp or jpg Format and then draw a rectangle containing a text block , The other is to manually save the picture as jpg or bmp Format .
Because there is only one wrong picture in the test picture , Simplicity , Directly use the drawing board to save it as jpg, rerun routine , It can be created normally Graphics Object and draw a rectangle containing a text block , The effect drawing is shown in the figure below ( The test pattern is derived from references 1).

reference :
[1]http://news.sohu.com/a/524033869_121124363
[2]https://docs.microsoft.com/zh-cn/dotnet/api/system.drawing.graphics.fromimage?redirectedfrom=MSDN&view=dotnet-plat-ext-6.0#System_Drawing_Graphics_FromImage_System_Drawing_Image_
[3]https://wenku.baidu.com/view/9db4726b757f5acfa1c7aa00b52acfc789eb9f99.html
[4]https://blog.csdn.net/w6579106/article/details/115865396
版权声明
本文为[gc_ two thousand two hundred and ninety-nine]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230516277571.html
边栏推荐
- Unity C e-learning (IV)
- 云计算与云原生 — OpenShift 的架构设计
- Devops life cycle, all you want to know is here!
- Power consumption parameters of Jinbei household mute box series
- 7-4 is it too fat (10 points) PTA
- Restful toolkit of idea plug-in
- Servlet3 0 + event driven for high performance long polling
- MySQL uses or to query SQL, and SQL execution is very slow
- Golang select priority execution
- 学习笔记:Unity CustomSRP-12-HDR
猜你喜欢

Servlet3 0 + event driven for high performance long polling

了解 DevOps,必读这十本书!

Minimum spanning tree -- unblocked project hdu1863

Discussion on flow restriction

Live delivery form template - automatically display pictures - automatically associate series products

看板快速启动指南

My old programmer's perception of the dangers and opportunities of the times?

Traversal of tree

2021-09-23

JSP-----JSP简介
随机推荐
Nacos source code startup error report solution
[2021] Spatio-Temporal Graph Contrastive Learning
DevOps生命周期,你想知道的全都在这里了!
Project manager's thinking mode worth trying: project success equation
Three 之 three.js (webgl)旋转属性函数的简单整理,以及基于此实现绕轴旋转的简单案例
Live delivery form template - automatically display pictures - automatically associate series products
How to exit VIM
Servlet3 0 + event driven for high performance long polling
学习笔记:Unity CustomSRP-10-Point and Spot Shadows
Discussion on flow restriction
Streamexecutionenvironment of Flink source code
calendar. Pit point of getactualmaximum (calendar. Day_of_month)
Some experience in using MySQL / tidb database [slowly updating...]
A trinomial expression that causes a null pointer
Locks and transactions in MySQL
使用zerotier让异地设备组局域网
mysql5. 7. X data authorization leads to 1141
The 2021 more reading report was released, and the book consumption potential of post-95 and Post-00 rose
Top 25 Devops tools in 2021 (Part 2)
【openh264】cmake: msopenh264-static