本文整理汇总了C++中CImage::GetPitch方法的典型用法代码示例。如果您正苦于以下问题:C++ CImage::GetPitch方法的具体用法?C++ CImage::GetPitch怎么用?C++ CImage::GetPitch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CImage
的用法示例。
在下文中一共展示了CImage::GetPitch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetRoundImage
//旋转图片
VOID CImageEditorControl::SetRoundImage(BYTE cbRoundType)
{
//状态效验
ASSERT(m_ImageSource.IsNull()==false);
if (m_ImageSource.IsNull()==true) return;
//构造位置
CSize SizeSource(m_ImageSource.GetWidth(),m_ImageSource.GetHeight());
CSize SizeResult(m_ImageSource.GetHeight(),m_ImageSource.GetWidth());
//创建位图
CImage ImageSource;
CImage ImageResult;
ImageSource.Create(m_ImageSource.GetWidth(),m_ImageSource.GetHeight(),32);
ImageResult.Create(m_ImageSource.GetHeight(),m_ImageSource.GetWidth(),32);
//绘画位图
CDC * pDCResult=CDC::FromHandle(ImageResult.GetDC());
CDC * pDCSource=CDC::FromHandle(ImageSource.GetDC());
m_ImageSource.BitBlt(pDCSource->m_hDC,0,0,m_ImageSource.GetWidth(),m_ImageSource.GetHeight(),0,0);
//获取属性
INT nPitchResult=ImageResult.GetPitch();
INT nPitchSource=ImageSource.GetPitch();
//获取数据
LPBYTE cbBitResult=(LPBYTE)ImageResult.GetBits();
LPBYTE cbBitSource=(LPBYTE)ImageSource.GetBits();
//创建区域
for (INT nYSourcePos=0;nYSourcePos<SizeSource.cy;nYSourcePos++)
{
for (INT nXSourcePos=0;nXSourcePos<SizeSource.cx;nXSourcePos++)
{
//目标位置
INT nXResultPos=(cbRoundType==ROUND_TYPE_LEFT)?nYSourcePos:(SizeSource.cy-nYSourcePos-1);
INT nYResultPos=(cbRoundType==ROUND_TYPE_LEFT)?(SizeSource.cx-nXSourcePos-1):nXSourcePos;
//设置颜色
DWORD dwSource=nYSourcePos*nPitchSource+nXSourcePos*4L;
DWORD dwResult=nYResultPos*nPitchResult+nXResultPos*4L;
*(COLORREF *)(cbBitResult+dwResult)=*(COLORREF *)(cbBitSource+dwSource);
}
}
//释放对象
ImageSource.ReleaseDC();
ImageResult.ReleaseDC();
//更新图片
if (LoadEditImage(ImageResult)==false)
{
ASSERT(FALSE);
return;
}
return;
}
示例2: DrawFaceNormal
//绘画头像
VOID CFaceItemControl::DrawFaceNormal(CDC * pDC, INT nXPos, INT nYPos, INT nWidth, INT nHeight, DWORD dwCustomFace[FACE_CX*FACE_CY])
{
//创建位图
CImage ImageCustomFace;
ImageCustomFace.Create(FACE_CX,FACE_CY,32);
//获取数据
INT nImagePitch=ImageCustomFace.GetPitch();
LPBYTE cbBitCustomFace=(LPBYTE)ImageCustomFace.GetBits();
//创建区域
for (INT nYImagePos=0;nYImagePos<FACE_CY;nYImagePos++)
{
for (INT nXImagePos=0;nXImagePos<FACE_CX;nXImagePos++)
{
//设置颜色
DWORD dwImageTarget=nYImagePos*nImagePitch+nXImagePos*4L;
*(COLORREF *)(cbBitCustomFace+dwImageTarget)=dwCustomFace[nYImagePos*FACE_CX+nXImagePos];
}
}
//绘画界面
ImageCustomFace.Draw(pDC->m_hDC,nXPos,nYPos,nWidth,nHeight);
return;
}
示例3: SetGray
bool CImageEx::SetGray()
{
CImage *pImage = &m_ImageClone;
if ( pImage == NULL && pImage->IsNull() )
{
pImage = this;
}
int nWidth = pImage->GetWidth();
int nHeight = pImage->GetHeight();
BYTE* pArray = (BYTE*)pImage->GetBits();
int nPitch = pImage->GetPitch();
int nBitCount = pImage->GetBPP() / 8;
for (int i = 0; i < nHeight; i++)
{
for (int j = 0; j < nWidth; j++)
{
int grayVal = (BYTE)(((*(pArray + nPitch * i + j * nBitCount) * 306)
+ (*(pArray + nPitch * i + j * nBitCount + 1) * 601)
+ (*(pArray + nPitch * i + j * nBitCount + 2) * 117) + 512 ) >> 10); // 计算灰度值
*(pArray + nPitch * i + j * nBitCount) = grayVal; // 赋灰度值
*(pArray + nPitch * i + j * nBitCount + 1) = grayVal;
*(pArray + nPitch * i + j * nBitCount + 2) = grayVal;
}
}
return true;
}
示例4: DrawFaceOffLine
//绘画头像
VOID CFaceItemControl::DrawFaceOffLine(CDC * pDC, INT nXPos, INT nYPos, INT nWidth, INT nHeight, DWORD dwCustomFace[FACE_CX*FACE_CY])
{
//创建位图
CImage ImageCustomFace;
ImageCustomFace.Create(FACE_CX,FACE_CY,32);
//获取数据
INT nImagePitch=ImageCustomFace.GetPitch();
LPBYTE cbBitCustomFace=(LPBYTE)ImageCustomFace.GetBits();
//创建区域
for (INT nYImagePos=0;nYImagePos<FACE_CY;nYImagePos++)
{
for (INT nXImagePos=0;nXImagePos<FACE_CX;nXImagePos++)
{
//设置颜色
DWORD dwImageTarget=nYImagePos*nImagePitch+nXImagePos*4L;
COLORREF crImageTarget=dwCustomFace[nYImagePos*FACE_CX+nXImagePos];
//提取颜色
BYTE cbColorR=GetRValue(crImageTarget);
BYTE cbColorG=GetGValue(crImageTarget);
BYTE cbColorB=GetBValue(crImageTarget);
BYTE cbColorGray=(BYTE)(cbColorR*0.30+cbColorG*0.59+cbColorB*0.11);
//设置颜色
*(COLORREF *)(cbBitCustomFace+dwImageTarget)=RGB(cbColorGray,cbColorGray,cbColorGray);
}
}
//绘画界面
ImageCustomFace.Draw(pDC->m_hDC,nXPos,nYPos,nWidth,nHeight);
return;
}
示例5: img_get_pxl
double img_get_pxl(int img_no, int i, int j, int channel) {
// Reading input texture sample
CImage* pImage = saved_images[img_no];
unsigned char *pData = (unsigned char*)pImage->GetBits();
int pitch = pImage->GetPitch();
int byte_pp = pImage->GetBPP() / 8;
//fout << "Initial sizeof: " << sizeof(pData) << std::endl;
if (pitch < 0)
{
//fout << "NEGATIVE; pitch = " << pitch << std::endl;
pData += pitch * (image_shapes[img_no].second - 1);
//pitch = -pitch;
}
/*for (int i = 0; i < pImage->GetHeight(); i++) // Image lines
{
for (int j = 0; j < pImage->GetWidth(); j++) // Pixels in line
{
unsigned char b = pCurrentLine[j * 4];
unsigned char g = pCurrentLine[j * 4 + 1];
unsigned char r = pCurrentLine[j * 4 + 2];
unsigned char alpha = pCurrentLine[j * 4 + 3];
}
pCurrentLine += pitch;
}*/
//fout << i << ' ' << pitch << ' ' << j << ' ' << byte_pp << ' ' << channel << std::endl << i * pitch + j * byte_pp + channel <<
// ' ' << sizeof(pData) << std::endl;
unsigned char *pxl_addr = (unsigned char *)pImage->GetPixelAddress(i, j); // j, i?
double pxl = double(*(pxl_addr + channel));
return pxl;
}
示例6: FilterImg
void Csmoothorsharp::FilterImg(int* temp,CImage imga){
int nW=imga.GetWidth()-1;
int nH=imga.GetHeight()-1;
byte *pRealData;
pRealData=(byte*)imga.GetBits();
int pit=imga.GetPitch();
int bitCount=imga.GetBPP()/8;
for (int i=1;i<nH;i++)
{
for (int j=1;j<nW;j++)
{
int Rval=0,Gval=0,Bval=0,indx=0;
for ( int row=-1;row<=1;row++)
{
for (int col=-1;col<=1;col++)
{
Bval+=((int)(int)(*(pRealData+pit*(i+row)+(j+col)*bitCount))) *temp[indx];
Gval=((int)(int)(*(pRealData+pit*(i+row)+(j+col)*bitCount+1)))*temp[indx];
Rval=((int)(int)(*(pRealData+pit*(i+row)+(j+col)*bitCount+2)))*temp[indx];
indx++;
}
}
//template work is over,You need get the center point pixel.
Rval=(int)(Rval*cval);
if (Rval>255)
Rval=255;
else if(Rval<0)
Rval=0;
Gval=(int)(Gval*cval);
if (Gval>255)
Gval=255;
else if(Gval<0)
Gval=0;
Bval=(int)(Bval*cval);
if (Bval>255)
Bval=255;
else if (Bval<0)
Bval=0;
//ok,write the new pixel into the pic.
*(pRealData+pit*(i-1)+(j-1)*bitCount)=Bval;
*(pRealData+pit*(i-1)+(j-1)*bitCount+1)=Gval;
*(pRealData+pit*(i-1)+(j-1)*bitCount+2)=Rval;
}
}
//CALL the OnDraw in MFC
}
示例7: OnOK
//确定函数
VOID CDlgCustomFace::OnOK()
{
//连接判断
bool bConnect=false;
//系统模式
if (m_cbMode==MM_SYSTEM)
{
CGlobalUserInfo * pGlobalUserInfo=CGlobalUserInfo::GetInstance();
bConnect=(pGlobalUserInfo->GetGlobalUserData()->wFaceID!=m_wFaceID);
}
//自定模式
if (m_cbMode==MM_CUSTOM)
{
//创建缓冲
CImage ImageCustomFace;
ImageCustomFace.Create(FACE_CX,FACE_CY,32);
//创建 DC
CImageDC BufferDC(ImageCustomFace);
m_FaceItemCustomWnd.DrawEditImage(CDC::FromHandle(BufferDC),0,0,FACE_CX,FACE_CY);
//获取数据
INT nImagePitch=ImageCustomFace.GetPitch();
LPBYTE cbBitCustomFace=(LPBYTE)ImageCustomFace.GetBits();
//创建区域
for (INT nYImagePos=0;nYImagePos<FACE_CY;nYImagePos++)
{
for (INT nXImagePos=0;nXImagePos<FACE_CX;nXImagePos++)
{
//设置颜色
DWORD dwImageTarget=nYImagePos*nImagePitch+nXImagePos*4L;
m_CustomFaceInfo.dwCustomFace[nYImagePos*FACE_CX+nXImagePos]=*(COLORREF *)(cbBitCustomFace+dwImageTarget);
}
}
//设置变量
bConnect=true;
m_CustomFaceInfo.dwDataSize=sizeof(m_CustomFaceInfo);
}
//激活任务
if (bConnect==true)
{
//控件控制
EnableControl(false);
//激活任务
m_MissionManager.AvtiveMissionItem(this,false);
return;
}
__super::OnOK();
}
示例8: InverseThread
UINT InverseThread(LPVOID pParam)
{
LANGID id = PIGetThreadUILanguage();
SetThreadUILanguage(id);
CString str;
str.LoadString(ID_IMAGE_INVERSE);
PIProgressInit(PI_PROGRESS_DLG, str);
// PIProgressInit(PI_PROGRESS_BAR, str);
CImage* pImage = (CImage*)pParam;
int nWidth = pImage->GetWidth();
int nHeight = pImage->GetHeight();
BYTE* pImageData = (BYTE*)pImage->GetBits();
int nPitch = pImage->GetPitch();
int nBitCount = pImage->GetBPP() / 8;
for (int j=0; j<nHeight; j++)
{
for (int i=0; i<nWidth; i++)
{
int nPixelIndex = j * nPitch + i * nBitCount;
BYTE* pPixel = pImageData + j * nPitch + i * nBitCount;
*(pPixel) = 255 - *(pPixel);
*(pPixel + 1) = 255 - *(pPixel + 1);
*(pPixel + 2) = 255 - *(pPixel + 2);
}
LRESULT lResult = PIProgressPercent(j * 100 / nHeight);
if (!lResult)
{
// quit thread
return 1;
}
}
PIProgressDone();
// refresh view
PIGetActiveView()->Invalidate(FALSE);
return 0;
}
示例9: MatToCImage
void CTraffic_Camera_Image::MatToCImage(Mat &mat, CImage &cImage)
{
//create new CImage
int width = mat.cols;
int height = mat.rows;
int channels = mat.channels();
//cImage.ReleaseDC();
//cImage.ReleaseGDIPlus();
cImage.Destroy(); //clear
cImage.Create(width,
height, //positive: left-bottom-up or negative: left-top-down
8*channels ); //numbers of bits per pixel
//copy values
uchar* ps;
uchar* pimg = (uchar*)cImage.GetBits(); //A pointer to the bitmap buffer
//The pitch is the distance, in bytes. represent the beginning of
// one bitmap line and the beginning of the next bitmap line
int step = cImage.GetPitch();
for (int i = 0; i < height; ++i)
{
ps = (mat.ptr<uchar>(i));
for ( int j = 0; j < width; ++j )
{
if ( channels == 1 ) //gray
{
*(pimg + i*step + j) = ps[j];
}
else if ( channels == 3 ) //color
{
for (int k = 0 ; k < 3; ++k )
{
*(pimg + i*step + j*3 + k ) = ps[j*3 + k];
}
}
}
}
}
示例10: SaveImageToFile
void CTracer::SaveImageToFile(std::string fileName)
{
CImage image;
int width = m_camera.m_resolution.x;
int height = m_camera.m_resolution.y;
image.Create(width, height, 24);
int pitch = image.GetPitch();
unsigned char* imageBuffer = (unsigned char*)image.GetBits();
if (pitch < 0)
{
imageBuffer += pitch * (height - 1);
pitch = -pitch;
}
int i, j;
int imageDisplacement = 0;
int textureDisplacement = 0;
for (i = 0; i < height; i++)
{
for (j = 0; j < width; j++)
{
glm::vec3 color = m_camera.m_pixels[textureDisplacement + j];
// clamp(val, minVal, maxVal) = min(max(x, minVal), maxVal)
// shows that val is in [minVal, maxVal]
imageBuffer[imageDisplacement + j * 3] = unsigned(glm::clamp(color.b, 0.0f, 1.0f) * 255.0f);
imageBuffer[imageDisplacement + j * 3 + 1] = unsigned(glm::clamp(color.g, 0.0f, 1.0f) * 255.0f);
imageBuffer[imageDisplacement + j * 3 + 2] = unsigned(glm::clamp(color.r, 0.0f, 1.0f) * 255.0f);
}
imageDisplacement += pitch;
textureDisplacement += width;
}
image.Save(fileName.c_str());
image.Destroy();
}
示例11:
void TestCommand::Func2()
{
CImage saveimg;
saveimg.Create(img_->GetWidth()/2,img_->GetHeight()/2,8);
int steps=m_min(img_->GetWidth()/2,img_->GetHeight()/2);
BYTE *psrc=(BYTE *)img_->GetImage()->GetBits();
int nrowsrc=img_->GetImage()->GetPitch();
BYTE *pdes=(BYTE *)saveimg.GetBits();
int nrowdes=saveimg.GetPitch();
for(int xi=0;xi<steps;xi++)
for(int yi=0;yi<steps;yi++)
{
pdes[yi*nrowdes+xi]=(psrc[(yi*2)*nrowsrc+(xi*2)*3]+psrc[(yi*2)*nrowsrc+(xi*2)*3+1]+psrc[(yi*2)*nrowsrc+(xi*2)*3+2]
+psrc[(yi*2)*nrowsrc+(2*xi+1)*3]+psrc[(yi*2)*nrowsrc+(2*xi+1)*3+1]+psrc[(yi*2)*nrowsrc+(2*xi+1)*3+2]
+psrc[(yi*2+1)*nrowsrc+(2*xi)*3]+psrc[(yi*2+1)*nrowsrc+(2*xi)*3+1]+psrc[(yi*2+1)*nrowsrc+(2*xi)*3+2]
+psrc[(yi*2+1)*nrowsrc+(2*xi+1)*3]+psrc[(yi*2+1)*nrowsrc+(2*xi+1)*3]+psrc[(yi*2+1)*nrowsrc+(2*xi+1)*3])/12;
}
saveimg.SetColorTable(0,255,ImageYH::GetColorTable());
saveimg.Save("d:\\testImg\\lena256.bmp");
}
示例12: CopyToImage
//
// Copies the content of a byte buffer to a MFC image with respect to the image's alignment
//
// Parameters:
// [in] pInbuffer The byte buffer as received from the cam
// [in] ePixelFormat The pixel format of the frame
// [out] OutImage The filled MFC image
//
void CAsynchronousGrabDlg::CopyToImage( VmbUchar_t *pInBuffer, VmbPixelFormat_t ePixelFormat, CImage &OutImage )
{
const int nHeight = m_ApiController.GetHeight();
const int nWidth = m_ApiController.GetWidth();
const int nStride = OutImage.GetPitch();
const int nBitsPerPixel = OutImage.GetBPP();
VmbError_t Result;
if( ( nWidth*nBitsPerPixel ) /8 != nStride )
{
Log( _TEXT( "Vimba only supports stride that is equal to width." ), VmbErrorWrongType );
return;
}
VmbImage SourceImage,DestinationImage;
SourceImage.Size = sizeof( SourceImage );
DestinationImage.Size = sizeof( DestinationImage );
SourceImage.Data = pInBuffer;
DestinationImage.Data = OutImage.GetBits();
Result = VmbSetImageInfoFromPixelFormat( ePixelFormat, nWidth, nHeight, &SourceImage );
if( VmbErrorSuccess != Result )
{
Log( _TEXT( "Error setting source image info." ), static_cast<VmbErrorType>( Result ) );
return;
}
static const std::string DisplayFormat( "BGR24" );
Result = VmbSetImageInfoFromString( DisplayFormat.c_str(),DisplayFormat.size(), nWidth,nHeight, &DestinationImage );
if( VmbErrorSuccess != Result )
{
Log( _TEXT( "Error setting destination image info." ),static_cast<VmbErrorType>( Result ) );
return;
}
Result = VmbImageTransform( &SourceImage, &DestinationImage,NULL,0 );
if( VmbErrorSuccess != Result )
{
Log( _TEXT( "Error transforming image." ), static_cast<VmbErrorType>( Result ) );
}
}
示例13: GetPixelColor
//根据文件路径获取单张图片
Texture2D* TextureLoader::CreateTexture2D(const char* fileName)
{
GLuint texture;
glGenTextures(1, &texture);
glBindTexture( GL_TEXTURE_2D, texture);
CImage *img = new CImage; // 新建CImage对象
char *complete_path = FileTool::GetInstance()->GetCompletePath(fileName);
if (complete_path == NULL)
{
SAFDelete(img);
return NULL;
}
wchar_t *wchat_file_name = ATC2W(complete_path);
img->Load(wchat_file_name); // 读入图像文件
SAFDelete(wchat_file_name);
SAFDelete(complete_path);
int width = img->GetWidth(); // 获取图像宽度
int height = img->GetHeight(); // 获取图像高度
int n = img->GetBPP() / 8;
int test = img->GetPitch();//图片是正的还是反的
GLubyte *image = new GLubyte[width * height * n]; // 用于保存图像数据的数组
// 将图像数据读入image数组
if(test<0)
for(int j = height-1,k=0; j >=0; j--,k++){
for(int i = width-1,z=width-1; i >=0; i--,z--){
int index = (k * width + z) * n;
RGBQUAD rgb = GetPixelColor(img, i, j);
image[index] = rgb.rgbRed;
image[index+1] = rgb.rgbGreen;
image[index+2] = rgb.rgbBlue;
if(n==4)
image[index+3] = rgb.rgbReserved;
}
}
else
for(int j = 0; j < height; j++){
for(int i = 0; i < width; i++){
int index = (j * width + i) * n;
RGBQUAD rgb = GetPixelColor(img, i, j);
image[index] = rgb.rgbRed;
image[index+1] = rgb.rgbGreen;
image[index+2] = rgb.rgbBlue;
if(n==4)
image[index+3] = rgb.rgbReserved;
}
}
delete img; // CImage对象已无用,数据已读入image数组
// 根据image中的数据在纹理内存中创建纹理
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // 每行图像数据紧密排列
if(n==4)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
else
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
delete image; // 纹理数据已在显卡纹理内存中了,主机内存中的image已无用
Texture2D *tex = new Texture2D();
tex->texture_name_ = fileName;
tex->height_ = height;
tex->width_ = width;
tex->tex_res_ = texture;
return tex;
}
示例14: UpdateView
//.........这里部分代码省略.........
}
EdsUInt32 size;
err = EdsGetLength(stream, &size);
if(err != EDS_ERR_OK)
{
printf("Error in EdsGetLength Histogram: 0x%X\n", err);
}
EdsImageRef image = NULL;
EdsImageInfo imageInfo;
err = EdsCreateImageRef(stream, &image);
if(err != EDS_ERR_OK)
{
printf("Error in EdsCreateImageRef: 0x%X\n", err);
}
err = EdsGetImageInfo(image, kEdsImageSrc_FullView, &imageInfo);
if(err != EDS_ERR_OK)
{
printf("Error in EdsGetImageInfo: 0x%X\n", err);
}
if(imageInfo.componentDepth != 8)
{
printf("Error imageInfo.componentDepth != 8\n");
}
liveImage = cvCreateImage(cvSize(imageInfo.width, imageInfo.height), IPL_DEPTH_8U, imageInfo.numOfComponents);
EdsUInt32 DataSize = 0;
CImage cImage;
HRESULT hr;
CComPtr<IStream> iStream = NULL;
HGLOBAL hMem = GlobalAlloc(GHND, size);
LPVOID pBuff = GlobalLock(hMem);
memcpy(pBuff, pByteImage, size);
GlobalUnlock(hMem);
hr = CreateStreamOnHGlobal(hMem, TRUE, &iStream);
// Get the bitmap image from the stream
if ((hr = cImage.Load(iStream)) == S_OK)
{
int pitch = cImage.GetPitch();
int height = cImage.GetHeight();
BYTE* pBits = (BYTE*)cImage.GetBits();
if (pitch < 0)
pBits += (pitch *(height -1));
memcpy(liveImage->imageData, pBits, abs(pitch) * height);
}
cImage.~CImage();
GlobalFree(hMem);
cvFlip(liveImage, NULL, 0);
// Release stream
if(stream != NULL)
{
err = EdsRelease(stream);
if(err != EDS_ERR_OK)
{
printf("Error in EdsRelease: 0x%X\n", err);
}
stream = NULL;
}
if(evfImage != NULL)
{
err = EdsRelease(evfImage);
if(err != EDS_ERR_OK)
{
printf("Error in EdsRelease: 0x%X\n", err);
}
evfImage = NULL;
}
EdsRelease(image);
cvShowImage(windowName.c_str(), liveImage);
cvReleaseImage(&liveImage);
}
示例15: BlendDrawImage
//混合绘画
bool CSkinImage::BlendDrawImage(CDC * pDestDC, INT xDest, INT yDest, INT cxDest, INT cyDest, INT xSrc, INT ySrc, COLORREF crTransColor, BYTE cbAlphaDepth)
{
//无效区域
CRect rcDirty;
pDestDC->GetClipBox(&rcDirty);
//绘画判断
if (IsNull()==true) return false;
//位置调整
tagImageRender ImageRender;
GetDrawImageArea(xDest,yDest,cxDest,cyDest,xSrc,ySrc,rcDirty,ImageRender);
//创建位图
CImage ImageResult;
CImage ImageSource;
ImageResult.Create(ImageRender.cxRender,ImageRender.cyRender,32);
ImageSource.Create(ImageRender.cxRender,ImageRender.cyRender,32);
//绘画位图
CDC * pDCImage=CDC::FromHandle(GetDC());
CDC * pDCResult=CDC::FromHandle(ImageResult.GetDC());
CDC * pDCSource=CDC::FromHandle(ImageSource.GetDC());
pDCSource->BitBlt(0,0,ImageRender.cxRender,ImageRender.cyRender,pDCImage,ImageRender.nXImage,ImageRender.nYImage,SRCCOPY);
pDCResult->BitBlt(0,0,ImageRender.cxRender,ImageRender.cyRender,pDestDC,ImageRender.nXScreen,ImageRender.nYScreen,SRCCOPY);
//获取属性
float fAlpha=(float)(cbAlphaDepth/255.0);
INT nPitchResult=ImageResult.GetPitch();
INT nPitchSource=ImageSource.GetPitch();
//获取数据
LPBYTE cbBitResult=(LPBYTE)ImageResult.GetBits();
LPBYTE cbBitSource=(LPBYTE)ImageSource.GetBits();
//创建区域
for (INT nYPos=0;nYPos<ImageRender.cyRender;nYPos++)
{
for (INT nXPos=0;nXPos<ImageRender.cxRender;nXPos++)
{
//获取颜色
COLORREF * pcrResult=(COLORREF *)(cbBitResult+nYPos*nPitchResult+nXPos*4);
COLORREF * pcrSource=(COLORREF *)(cbBitSource+nYPos*nPitchSource+nXPos*4);
//混合处理
if (*pcrSource!=crTransColor)
{
//结果颜色
BYTE cbResultR=GetRValue(*pcrResult);
BYTE cbResultG=GetGValue(*pcrResult);
BYTE cbResultB=GetBValue(*pcrResult);
//原图颜色
BYTE cbSourceR=GetRValue(*pcrSource);
BYTE cbSourceG=GetGValue(*pcrSource);
BYTE cbSourceB=GetBValue(*pcrSource);
//颜色混合
cbResultR=(BYTE)(cbSourceR*fAlpha+cbResultR*(1.0-fAlpha));
cbResultG=(BYTE)(cbSourceG*fAlpha+cbResultG*(1.0-fAlpha));
cbResultB=(BYTE)(cbSourceB*fAlpha+cbResultB*(1.0-fAlpha));
//颜色混合
*pcrResult=RGB(cbResultR,cbResultG,cbResultB);
}
}
}
//绘画界面
ImageResult.BitBlt(pDestDC->m_hDC,ImageRender.nXScreen,ImageRender.nYScreen);
//释放对象
ReleaseDC();
ImageSource.ReleaseDC();
ImageResult.ReleaseDC();
return true;
}