有哪位知道如何转换呢?谢谢了!希望调用格式如下://pBitmap 是已经获得的图片
BOOL ConvertToBW(Bitmap *pBitmap)
{ } 看了很多代码都不懂。再次谢谢!
BOOL ConvertToBW(Bitmap *pBitmap)
{ } 看了很多代码都不懂。再次谢谢!
解决方案 »
- 谁帮个忙 要做个自动更新
- vc6.0可以编译,当不能调试,无论是dll还是exe,设断点后运行调试vc就死掉了....
- 请问如何在对话框中显示jpg图片?
- 如何模拟键盘按住alt键和ascii值来输入中文和英文?在线急等!
- 〔社会调查〕因为有些问题不知道找哪位高手可以解答,所以做个调查
- DLL文件是否可以“直接”放到内存中然后在调用里面的函数??UP有分!
- 如何在vc中实现一个按扭的buttondown,buttonmousemove,buttonup等代码
- 泣求指出错误!并提供资料和例程
- ◀◀◀◀在广州的湖北的程序员出来冒个泡啊,过年啦,聊聊啊▶▶▶▶▶
- 请教有到日本企业面试经验的朋友,拜托给点意见
- OnPaint()函数中绘制图形随窗口缩放按比例调整位置和大小。
- 怎样用函数画正圆?
bw - black and white image file format and utilitiesformat
a bw file contains sequences of pixels. each pixel is
stored as one unsigned char, and thus ranges in intensity
from 0 (black) to 255 (white). the first pixel in a bw file
is the lower left corner of the image. the pixels proceed
from left-to-right across each scanline, with scanlines
being written from the bottom to the top of the image.by convention, bw images are usually square, and thus their
dimensions can be determined by the file size. if this is
not the case, often only the file width need be known by a
program reading the file. history has left us with two
"standard" sizes, 512x512 and the "hires" 1024x1024. a com-
mon practice for other file sizes is to include the file
width in the filename.at some time in the future bw files will probably get self-
typing headers so that parameters such as their size can be
automatically determined by programs.utilities
bw-fb display a .bw format image on a framebuffer.
fb-bw produce a .bw file from a framebuffer image.
bw-pix convert a .bw file to a color .pix file.
pix-bw convert a color .pix file to a .bw file.
bwstat gives statistics concerning a .bw file.
bwhist displays a histogram on a framebuffer.
bwmod a filter to shift and scale pixel intensities.
bwdiff yields the difference between two .bw files.
bwrect extracts an arbitrary rectangle from a .bw file.
bwcrop maps any quadrilateral in a .bw file into any rectan-
gle.
bwrot rotates, reverses, or inverts a .bw file.
bwscale scales a .bw file larger or smaller.
bwfilter a variety of 3x3 kernel filters for .bw images.
bw3-pix merges three .bw files into one .pix file.
pix-bw3 separates .pix file rgb colors into three .bw files.files
file.bwsee also
brlcad(1), pix(5), and above named programs.
void CPalmDoc::OnGray()
{
// TODO: Add your command handler code here int i,j;
unsigned char *lpSrc,*lpDst;//一个指向源、目的像素的移动指针 //对源图像进行操作
LPSTR lpDIB = (LPSTR) ::GlobalLock((HGLOBAL)m_hDIB);
int cxDIB = (int) ::DIBWidth(lpDIB);
int cyDIB = (int) ::DIBHeight(lpDIB);
LPSTR lpDIBBits=::FindDIBBits (lpDIB); //找到源图像中图像数据区起始位置
long lLineBytesSrc = WIDTHBYTES(cxDIB * 8 * 3);// 计算源24位真彩图像每行的字节数 int numColors=(int) ::DIBNumColors((char *)lpDIB);
if (numColors!=0) //如果numColors是0,则表示目前图像为24位真彩图
{
::GlobalUnlock((HGLOBAL) m_hDIB);
return;
} //新创建一个8位(256级灰度)的DIB句柄
HDIB grayhDIB=NewDIB(cxDIB, cyDIB,8);
LPSTR glpDIB=(LPSTR)::GlobalLock((HGLOBAL)grayhDIB);
LPSTR glpDIBBits=::FindDIBBits (glpDIB);
long lLineBytesDst = WIDTHBYTES(cxDIB * 8);// 计算目标8位灰度图像每行的字节数
// 每行
for(i = 0; i < cyDIB; i++)
{
//每列
for(j = 0; j < cxDIB; j++)
{
// 指向DIB第i行,第j个象素的指针(这里的行为从上到下的)
lpSrc = (unsigned char*)lpDIBBits + lLineBytesSrc * (cyDIB - 1 - i) + j*3;
lpDst = (unsigned char*)glpDIBBits + lLineBytesDst * (cyDIB - 1 - i) + j;
*lpDst=(*lpSrc)/3+(*(lpSrc+1))/3+(*(lpSrc+2))/3;
}
} m_hDIB=grayhDIB;
::GlobalUnlock((HGLOBAL) m_hDIB);
::GlobalUnlock((HGLOBAL) grayhDIB);
UpdateAllViews(NULL, 0, NULL);
}
可以直接调的通