如何删除位图中的像素? [英] how can a pixel in a bitmap can be deleted?
本文介绍了如何删除位图中的像素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对所有周围像素的值求平均值,将该值存储在选定的像素位置,然后删除所有周围像素.因此4 * 6矩阵变为4 x 3矩阵.
我正在通过此代码访问像素
for ( int y = 0 ; y< bmp.bmHeight; y ++)
{
for ( int x = 0 ; x < bmp.bmWidth; x ++)
{
COLORREF rgb = dc.GetPixel(x,y);
BYTE r = GetRValue(rgb);
字节g = GetGValue(rgb);
字节b = GetBValue(rgb);
dc.SetPixel(x,y,RGB(r,g,b));
}
}
告诉我如何删除像素?
解决方案
我不认为您可以(或者真的想要这么做,这会破坏循环)执行平均值).
IMO需要做的是以新分辨率的大小创建目标.bmp,然后将平均值复制到相应的像素中.这也会为您留出还原"选项以备将来使用.
i m decreasing the resolution of a bitmap. i found a method on a site which is as follows
Average the values of all surrounding pixels, store that value in the choosen pixel location, then delete all the surrounding pixels.so a 4*6 matrix becomes a 4 x 3 matrix.
i am accessing pixels by this code
for(int y = 0; y < bmp.bmHeight; y++)
{
for(int x = 0; x < bmp.bmWidth; x++)
{
COLORREF rgb = dc.GetPixel(x, y);
BYTE r = GetRValue(rgb);
BYTE g = GetGValue(rgb);
BYTE b = GetBValue(rgb);
dc.SetPixel(x, y, RGB(r,g,b));
}
}
tell me how can i delete a pixel?
解决方案
I don''t think you can (or would really want to for that ,matter, it would smash the loop performing the averages).
What you need to do IMO is to create a target .bmp at the size of the new resolution, and copy the averaged values into corresponding pixel. This will also leave you an "revert" option for future use.
这篇关于如何删除位图中的像素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文