解决方案 »
- 关于IOCP(完成端口):在使用postqueuedcompletionstatus函数退出完成端口之前需要关闭套接字吗?
- 求助,帮忙解释一下这个用法
- 线程原来越多,怎么样删除线程
- DeviceIoControl出错返回ERROR_SEM_TIMEOUT(121)
- static int i=1 与 static int i;i=1;区别
- 急求调用 " UpdateLayeredWindow() " 这个API的方法??
- 高分求pop3收邮件的程序源代码,要求能收附件
- 结构体该如何存储
- 理解消息映射的机制真的对写程序有很大帮助?
- 求助!mfc新手小问题!
- 驱动新手ObReferenceObjectByHandle的问题
- 如何在一张图片中,提取车的轮廓?(思路)
BITMAPINFO* pInfo = (BITMAPINFO*)malloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));//分配空间
BITMAPINFOHEADER Info_Header;
Info_Header.biSize = sizeof(BITMAPINFOHEADER);
Info_Header.biWidth = nBmpWidth;
Info_Header.biHeight = nBmpHeight;
Info_Header.biPlanes = 1;
Info_Header.biBitCount = 24;
Info_Header.biCompression = BI_RGB;
Info_Header.biSizeImage = nBmpHeight * nBmpWidth*3;
Info_Header.biXPelsPerMeter = 0;
Info_Header.biYPelsPerMeter = 0;
Info_Header.biClrUsed = 0;
Info_Header.biClrImportant = 0;
for(int i=0; i<256; i++)
{
pInfo->bmiColors[i].rgbBlue = (BYTE)i;
pInfo->bmiColors[i].rgbGreen = (BYTE)i;
pInfo->bmiColors[i].rgbRed = (BYTE)i;
pInfo->bmiColors[i].rgbReserved = 0;
}
memcpy(pInfo, &Info_Header, sizeof(BITMAPINFOHEADER));
return pInfo;
能确定 调色板是 256 项 吗 ?
{
Bitmap myBitmap(L"Myimage2.jpg"); // 57,858 字节
m_nBmpWidth = myBitmap.GetWidth();// 650
if(m_nBmpWidth==0) return;
//
m_nBmpHeight=myBitmap.GetHeight();// 600
if(m_nBmpHeight==0) return;
//
Color backColor;// Argb 0xff000000
myBitmap.GetHBITMAP(backColor, &m_hBitmap);
if(m_hBitmap ==0 ) return;
//
PixelFormat pf=myBitmap.GetPixelFormat();
if(pf == PixelFormat24bppRGB)
{
afxDump << "The pixel format of is 24bppRGB.\n";
}
...格式 PixelFormat24bppRGB
应该没有调色板.
{
Bitmap myBitmap(L"Myimage2.jpg"); // 57,858 字节
m_nBmpWidth = myBitmap.GetWidth();// 650
if(m_nBmpWidth==0) return;
//
m_nBmpHeight=myBitmap.GetHeight();// 600
if(m_nBmpHeight==0) return;
// check format
PixelFormat pf=myBitmap.GetPixelFormat();
if(pf != PixelFormat24bppRGB) return;
// make new
Bitmap *pBitmap=myBitmap.Clone(0,0,m_nBmpWidth,m_nBmpHeight,pf);
// upside down !
Color mycolor;
for(int i = 0; i < m_nBmpHeight; i++)
{
for(int j = 0; j < m_nBmpWidth; j++)//x--width
{
myBitmap.GetPixel(j,i,&mycolor);//获得像素值
pBitmap->SetPixel(j,m_nBmpHeight-1-i,mycolor);
}
}
// for paint
Color backColor; // Argb 0xff000000
pBitmap->GetHBITMAP(backColor, &m_hBitmap);
if(m_hBitmap ==0 ) return;
}
//////////////////////////////////
void CMyImageDlg::OnPaint()
......
else
{
CPaintDC dc(this); // device context for painting
if(m_hBitmap)
{
CDC memDC;
memDC.CreateCompatibleDC(&dc);
HBITMAP hold=(HBITMAP)memDC.SelectObject(m_hBitmap);
CRect rc;
GetClientRect(&rc);
dc.SetStretchBltMode(HALFTONE);
dc.StretchBlt(rc.left,rc.top,rc.Width(),rc.Height(),&memDC,
0,0,m_nBmpWidth,m_nBmpHeight,SRCCOPY);
// free
memDC.SelectObject(hold);
}