当前位置:网站首页>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 .
边栏推荐
- 一文读懂数仓中的pg_stat
- 整理几个重要的Android知识,高级Android开发面试题
- 最新阿里P7技术体系,妈妈再也不用担心我找工作了
- Sort out several important Android knowledge and advanced Android development interview questions
- 预售17.9万,恒驰5能不能火?产品力在线,就看怎么卖
- 最新高频Android面试题目分享,带你一起探究Android事件分发机制
- AutoLISP series (1): function function 1
- 【医学分割】attention-unet
- 01tire+ chain forward star +dfs+ greedy exercise one
- Binary search tree (basic operation)
猜你喜欢
随机推荐
"The" "PIP" "entry cannot be recognized as the name of a cmdlet, function, script file, or runnable program."
Cesium (4): the reason why gltf model is very dark after loading
Temperature sensor chip used in temperature detector
字节跳动Android金三银四解析,android面试题app
Three. JS series (1): API structure diagram-1
最新高频Android面试题目分享,带你一起探究Android事件分发机制
在哪个期货公司开期货户最安全?
Personal notes of graphics (4)
dapp丨defi丨nft丨lp单双币流动性挖矿系统开发详细说明及源码
Have fun | latest progress of "spacecraft program" activities
编程模式-表驱动编程
LeetCode 300. 最长递增子序列 每日一题
SqlServer2014+: 创建表的同时创建索引
Usage of config in laravel
如何快速检查钢网开口面积比是否符合 IPC7525
LeetCode 1155. 掷骰子的N种方法 每日一题
作为Android开发程序员,android高级面试
logback. XML configure logs of different levels and set color output
全网“追杀”钟薛高
最新2022年Android大厂面试经验,安卓View+Handler+Binder