RT..
CBitmap bmTotal;
bmTotal.LoadBitmap(IDB_BITMAP_TOTAL);其中IDB_BITMAP_TOTAL图片为2张我需要图的组合.
定义CBitmap bm1,bm2;
如何把IDB_BITMAP_TOTAL图片对半拆分到上面两个CBitmap变量中?
CBitmap bmTotal;
bmTotal.LoadBitmap(IDB_BITMAP_TOTAL);其中IDB_BITMAP_TOTAL图片为2张我需要图的组合.
定义CBitmap bm1,bm2;
如何把IDB_BITMAP_TOTAL图片对半拆分到上面两个CBitmap变量中?
解决方案 »
- 实在是郁闷,请问32位和64位的驱动,源代码有什么不一样????
- 加载ActiveX的页面多次刷新就出错
- 如何设置ClistCtrl的风格
- _TCHAR,TCHAR,TEXT,_TEXT有何区别?
- 求教:如何修改系统鼠标指针?
- 在线给分:有一条直线从(0,0)到(10,13),有一个点(x,y),怎样才能知这个点是否在直线上 ?
- ((")("))各位好!我想用Crystal report 4.6 , 1.创建不带数据库连接的报表。2.而且带表格的(除了插入excel或word 对象方法还有更好的办
- 用VC SDK怎么加载'树型控件'?
- 求教高手 如何用VC++编写对数据库自动备份和恢复
- RichEdit中的ActiveX控件怎么不响应事件
- 关于指针的基础问题
- 初学钩子,局部钩子和全局钩子该如何选择使用?
比如获得一个指定大小、位置等参数的位图对象可以用Clone()Bitmap::Clone Methods
This topic lists the Clone methods of the Bitmap class. For a complete list of methods for the Bitmap class, see Bitmap Methods. Clone()
Clone(Rect& rect, PixelFormat format)
Clone(RectF& rect, PixelFormat format)
Clone(INT x, INT y, INT width, INT height, PixelFormat format)
Clone(REAL x, REAL y, REAL width, REAL, height, PixelFormat format)
StretchBlt的确可以实现..不过我还是需要能放到2个CBitmap里备用..
还有其他的办法没?
HDC hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
DWORD dwRop // raster operation code
);
BitBlt的目标不能为CBitmap类型吧..
{
BITMAP bitmap;
SourceBitmap->GetBitmap(&bitmap);
int width=bitmap.bmWidth;
//目前只能处理24位位图
if(x>=bitmap.bmWidth || y>=bitmap.bmHeight || 32!=bitmap.bmBitsPixel)
return FALSE;
if(x+nWidth>=bitmap.bmWidth)
nWidth=bitmap.bmWidth-x;
if(y+nHeight>=bitmap.bmHeight)
nHeight=bitmap.bmHeight-y;
SourceBit=new BYTE[bitmap.bmWidth*bitmap.bmHeight*4];
SubBit=new BYTE[nWidth*nHeight*4];
SourceBitmap->GetBitmapBits(bitmap.bmWidth*bitmap.bmHeight*4,SourceBit);
SubBitmap->DeleteObject(); //先清空原有的图片
bitmap.bmWidth=nWidth;
bitmap.bmHeight=nHeight;
bitmap.bmWidthBytes=nWidth*4;
SubBitmap->CreateBitmapIndirect(&bitmap);
BYTE *temp=SubBit;
for(int i=y;i<nHeight+y;i++)
{
for(int j=x;j<nWidth+x;j++)
{
*(temp++)=*(SourceBit+4*i*width+4*j);
*(temp++)=*(SourceBit+4*i*width+4*j+1);
*(temp++)=*(SourceBit+4*i*width+4*j+2);
*(temp++)=*(SourceBit+4*i*width+4*j+3);
}
}
SubBitmap->SetBitmapBits(nWidth*nHeight*4,SubBit);
return TRUE;
}
pWnd->ModifyStyle(0, SS_BITMAP);
CBitmap source,sub;
source.LoadBitmap(IDB_BITMAP1);
BYTE *SourceBit=0,*SubBit=0;
if(Clone(&source,&sub,SourceBit,SubBit,10,10,250,250))
pWnd->SetBitmap(sub);
if(NULL!=SourceBit)
{
delete[]SourceBit;
SourceBit=NULL;
}
if(NULL!=SubBit)
{
delete[]SubBit;
SubBit=NULL;
}
我这出问题了.当把显示器调为16位色的时候Clone函数不启作用.求助!!!!
感觉上好像是由bitmap.bmBitsPixel/8得来的,但是当16位的时候即为2,替换后程序运行会崩溃,无解了。