| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 576 人关注过本帖
标题:救命!
只看楼主 加入收藏
xsb002
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2005-11-16
收藏
 问题点数:0 回复次数:2 
救命!
我有一个函数,总是通不过,急得我快发疯了。
搜索更多相关主题的帖子: 救命 
2005-11-16 21:32
xsb002
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2005-11-16
收藏
得分:0 

LRESULT CALLBACK FrameCallbackProc(HWND hWnd, LPVIDEOHDR lpVHdr)
{
char str[50];
HDC hdc,drc;
hdc=CreateCompatibleDC(GetDC (NULL));
drc=CreateCompatibleDC(GetDC (NULL));
HBITMAP bit,bmp,tmp;
int cs;
BITMAPINFO info1;
bit=CreateCompatibleBitmap(hdc,info1.bmiHeader.biWidth ,abs(info1.bmiHeader.biHeight ) );
tmp=CreateCompatibleBitmap(drc,info1.bmiHeader.biWidth ,abs(info1.bmiHeader.biHeight ) );

capGetVideoFormat(hWnd, &info1, sizeof(info1));

if(info1.bmiHeader.biCompression == BI_RGB)
{
cs = SetDIBits(hdc, bit, 1, 240 ,lpVHdr->lpData, &info1, DIB_RGB_COLORS);
// HBITMAP tmp=CreateDIBitmap(drc,&info1.bmiHeader,CBM_INIT,bit,&info1,DIB_RGB_COLORS);

FILE *fp=fopen("d:\\bmp.bmp","wb");
file://fwrite(&bit,sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+lpVHdr->dwBufferLength,1,fp);
fwrite(&bit,lpVHdr->dwBufferLength,1,fp);
fclose(fp);
// LPBYTE DataPoint;

// DataPoint=(LPBYTE)malloc(lpVHdr->dwBufferLength);

// memcpy( DataPoint, lpVHdr->lpData, lpVHdr->dwBufferLength );


// HBITMAP bmp=(HBITMAP )LoadImage(NULL,"d:\\bbmp.bmp",0,0,0,16);
// HBITMAP bmp=(HBITMAP)DataPoint;

file://LONG aa=Color_S(bmp,H_x,H_y,H_w,H_h);
LONG aa=CountColor (tmp,H_x,H_y,H_w,H_h);
file://free(DataPoint);
sprintf(str,"%u",bmp);
MessageBox(0,str,"",0);}

DeleteObject(tmp);

DeleteObject(bit);
DeleteDC (hdc);
DeleteDC (drc);
return (LRESULT) TRUE ;
}

2005-11-16 21:33
xsb002
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2005-11-16
收藏
得分:0 

LONG WINAPI CountColor (HBITMAP hBmp,int x,int y,int width,int height)
file://COLORREF cOldColor,COLORREF cNewColor,)
{
LONG col=0;
char str[40];
HBITMAP RetBmp=NULL;
HBITMAP hhBmp=NULL;
if (hBmp)
{
HDC BufferDC=CreateCompatibleDC(NULL); // 源位图

if (BufferDC)
{
hhBmp=(HBITMAP)SelectObject(BufferDC,hBmp);//

HDC DirectDC=CreateCompatibleDC(NULL); // 目标DC
if (DirectDC)
// 获取源位图大小]f=CK
{
BITMAP bm;
GetObject(hhBmp, sizeof(bm), &bm);

// 初始化BITMAPINFO信息,以便使用CreateDIB
BITMAPINFO RGB32BitsBITMAPINFO;
ZeroMemory(&RGB32BitsBITMAPINFO,sizeof(BITMAPINFO));
RGB32BitsBITMAPINFO.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
RGB32BitsBITMAPINFO.bmiHeader.biWidth=bm.bmWidth;
RGB32BitsBITMAPINFO.bmiHeader.biHeight=bm.bmHeight;
RGB32BitsBITMAPINFO.bmiHeader.biPlanes=1;
RGB32BitsBITMAPINFO.bmiHeader.biBitCount=32;
UINT * ptPixels;
HBITMAP DirectBitmap= CreateDIBSection(DirectDC,(BITMAPINFO *)
&RGB32BitsBITMAPINFO,DIB_RGB_COLORS,(void **)&ptPixels, NULL, 0);
if (DirectBitmap)
{
HGDIOBJ PreviousObject=SelectObject(DirectDC, DirectBitmap);
BitBlt(DirectDC,0,0,width,height,BufferDC,x,y,SRCCOPY);
// 转换 COLORREF 为 RGBb54
// cOldColor=COLORREF2RGB(cOldColor);
// cNewColor=COLORREF2RGB(cNewColor);
// 替换颜色\O_
// sprintf(str,"%u",GetPixel(PreviousObject,10,10));
// MessageBox(0,str,"",0);
// sprintf(str,"%u",GetPixel(PreviousObject,80,40));
// MessageBox(0,str,"",0);

for (int i=((bm.bmWidth*bm.bmHeight)-1);i>=0;){

col=col+ptPixels[i];
// if (ptPixels[i]==cOldColor) ptPixels[i]=cNewColor;
i=i-1000;}
// for(int i=1;i<bm.bmWidth;){
// for(int m=1;m<bm.bmHeight;)
// {col=col+GetPixel(BufferDC,i,m);
// m=m+10;}
// i=i+10;}
// 修改位图 DirectBitmapx>6
SelectObject(DirectDC,PreviousObject);

// 完成w"Nq
// RetBmp=DirectBitmap;}
DeleteObject(PreviousObject);}
// 释放DC@
DeleteDC(DirectDC);

}
// DeleteObject(hhBmp);
// 释放DCe8tZ>q
DeleteDC(BufferDC);
}

}
file://return RetBmp;
return col;
}

2005-11-16 21:34
快速回复:救命!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.034598 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved