当前位置:网站首页>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
边栏推荐
- Master-slave replication of MariaDB database
- QPushButton slot function is triggered multiple times
- Asynchronous iterator & asynchronous generator & asynchronous context manager
- 改进DevSecOps框架的 5 大关键技术
- Some experience in using MySQL / tidb database [slowly updating...]
- Where, on when MySQL external connection is used
- 2021 年 25 大 DevOps 工具(下)
- Pandas to_ SQL function pit avoidance guide "with correct code to run"
- JSP -- Introduction to JSP
- The vscode ipynb file does not have code highlighting and code completion solutions
猜你喜欢
What role do tools play in digital transformation?
Top 25 Devops tools in 2021 (Part 2)
2022/4/22
[2021] Spatio-Temporal Graph Contrastive Learning
Deep learning notes - object detection and dataset + anchor box
Unique primary key ID of tidb sub table -- solution to failure of sequence and Gorm to obtain primary key
工具在数字化转型中扮演了什么样的角色?
了解 DevOps,必读这十本书!
When is it appropriate for automated testing? (bottom)
[2022 ICLR] Pyramid: low complexity pyramid attention for long range spatiotemporal sequence modeling and prediction
随机推荐
Locks and transactions in MySQL
What are the reasons for the failure of digital transformation?
源码剖析Redis中如何使用跳表的
The difference between static pipeline and dynamic pipeline
Kanban Quick Start Guide
Swing display time (click once to display once)
Kubectl command automatic replenishment
Deep learning notes - data expansion
看板快速启动指南
Routing parameters
Pandas to_ SQL function pit avoidance guide "with correct code to run"
Discussion on flow restriction
API slow interface analysis
MySQL views the SQL statement details executed by the optimizer
Three 之 three.js (webgl)旋转属性函数的简单整理,以及基于此实现绕轴旋转的简单案例
Good simple recursive problem, string recursive training
C#测试调用PaddleSharp模块识别图片文字
学习笔记:Unity CustomSRP-10-Point and Spot Shadows
Power consumption parameters of Jinbei household mute box series
Golang select priority execution