解决方案 »
- 关于c++图像处理的钱途
- 求教<windows核心编程>中"通过改写代码来挂接API "的问题
- 求助:这段代码定义什么类型?
- 怎么在dialog上画位图,我这段代码为什么不行?
- 如何获得一个字符或者一个字符串在界面上显示的宽度(高度)?
- char* 的问题,请各位给我指点指点!
- windows2000下 使用CSocket编程返回错误"10093"
- 《MFC WINDOWS程序设计》与《VC++技术内幕》,《深入浅出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);
}