当前位置:网站首页>QT picture background color pixel processing method
QT picture background color pixel processing method
2022-07-07 16:58:00 【God port】
Preface
stay qt In development , We often deal with background pictures , For example, I just want to get a part of the picture , Next, we use the most original image processing method to achieve the effect .
step
Let's put an original picture first
Then we want to change the white part into the background color
Ideas :
Get all the pixels of this picture , For each pixel rgb Color judgment , If it's the color you want to change , Then we will change this pixel into a transparent color ( Or the color you want to change )
Code
QImage image(":/CustomAddControl/1.bmp");// Load the original image
int w, h;
// Get the width and height of the picture
w = image.width();
h = image.height();
// Traverse every pixel
for (int i = 0; i < h; i++)
{
for (int j = 0; j < w; j++)
{
QRgb rgb = image.pixel(j, i);
if (rgb == 0xFFFFFFFF) // If it matches the background color
{
image.setPixel(j, i, 0x00000000);// This pixel is set to transparent
}
}
}
QPixmap tempPixmap = QPixmap::fromImage(image);// Processed pictures
And then we use label Show contrast effect :
obviously , We found that the white and other areas of the original image became transparent and were covered by the background color , In this way, we can achieve a simple image embedding effect .
summary
This treatment is relatively primitive , We can filter pictures based on this object 、 To strengthen 、 A series of image processing technologies such as sawtooth , Just multiply the pixels by an image processing matrix , The specific algorithm can search by itself , This article will not explain too much .
边栏推荐
- 最新阿里P7技术体系,妈妈再也不用担心我找工作了
- Master this promotion path and share interview materials
- 深度监听 数组深度监听 watch
- 二叉搜索树(特性篇)
- node:504报错
- LeetCode 1696. 跳跃游戏 VI 每日一题
- "The" "PIP" "entry cannot be recognized as the name of a cmdlet, function, script file, or runnable program."
- 预售17.9万,恒驰5能不能火?产品力在线,就看怎么卖
- URL和URI的关系
- Three. JS series (2): API structure diagram-2
猜你喜欢
随机推荐
整理几个重要的Android知识,高级Android开发面试题
Three. JS series (3): porting shaders in shadertoy
Cesium(3):ThirdParty/zip. js
Read PG in data warehouse in one article_ stat
Pycharm terminal enables virtual environment
Talk about the realization of authority control and transaction record function of SAP system
Localstorage and sessionstorage
Three. JS series (2): API structure diagram-2
《产品经理必读:五种经典的创新思维模型》的读后感
【Android -- 数据存储】使用 SQLite 存储数据
面向接口编程
logback. XML configure logs of different levels and set color output
AutoLISP series (3): function function 3
如何选择合适的自动化测试工具?
Laravel changed the session from file saving to database saving
three. JS create cool snow effect
Opportunity interview experience summary
LeetCode 1774. 最接近目标价格的甜点成本 每日一题
1亿单身男女“在线相亲”,撑起130亿IPO
直接上干货,100%好评