コード例 #1
0
ファイル: ximasel.cpp プロジェクト: Valloric/hge-multi
/**
 * Creates the selection channel from a gray scale image.
 * black = unselected
 */
bool CxImage::SelectionSet(CxImage &from)
{
	if (!from.IsGrayScale() || head.biWidth != from.head.biWidth || head.biHeight != from.head.biHeight){
		strcpy(info.szLastError,"CxImage::SelectionSet: wrong width or height, or image is not gray scale");
		return false;
	}

	if (pSelection==NULL) pSelection = (uint8_t*)malloc(head.biWidth * head.biHeight);

	uint8_t* src = from.info.pImage;
	uint8_t* dst = pSelection;
	if (src==NULL || dst==NULL){
		strcpy(info.szLastError,"CxImage::SelectionSet: null pointer");
		return false;
	}

	for (int32_t y=0; y<head.biHeight; y++){
		memcpy(dst,src,head.biWidth);
		dst += head.biWidth;
		src += from.info.dwEffWidth;
	}

	SelectionRebuildBox();

	return true;
}
コード例 #2
0
ファイル: ximalpha.cpp プロジェクト: gotoshake/quick-cc
bool CxImage::AlphaSet(CxImage &from)
{
	if (!from.IsGrayScale() || head.biWidth != from.head.biWidth || head.biHeight != from.head.biHeight) return false;
	if (pAlpha==NULL) pAlpha = (BYTE*)malloc(head.biWidth * head.biHeight);
	BYTE* src = from.info.pImage;
	BYTE* dst = pAlpha;
	for (long y=0; y<head.biHeight; y++){
		memcpy(dst,src,head.biWidth);
		dst += head.biWidth;
		src += from.info.dwEffWidth;
	}
	return true;
}
コード例 #3
0
ファイル: ximalpha.cpp プロジェクト: BearKidsTeam/SMELT
/**
 * Creates the alpha channel from a gray scale image.
 */
bool CxImage::AlphaSet(CxImage &from)
{
	if (!from.IsGrayScale() || head.biWidth != from.head.biWidth || head.biHeight != from.head.biHeight) return false;
	if (pAlpha==NULL) pAlpha = (uint8_t*)malloc(head.biWidth * head.biHeight);
	uint8_t* src = from.info.pImage;
	uint8_t* dst = pAlpha;
	if (src==NULL || dst==NULL) return false;
	for (int32_t y=0; y<head.biHeight; y++){
		memcpy(dst,src,head.biWidth);
		dst += head.biWidth;
		src += from.info.dwEffWidth;
	}
	return true;
}
コード例 #4
0
/**
 * Creates the alpha channel from a gray scale image.
 */
bool CxImage::AlphaSet(CxImage &from)
{
	if (!from.IsGrayScale() || head.biWidth != from.head.biWidth || head.biHeight != from.head.biHeight) return false;
	if (!bAlpha)
	{
        return false;
	}
    
    //if (pAlpha==NULL) pAlpha = (uint8_t*)malloc(head.biWidth * head.biHeight);
	uint8_t* src = from.info.pImage;
	//uint8_t* dst = pAlpha;
	if (src==NULL) return false;
	for (int32_t y=0; y<head.biHeight; y++){
        for (int32_t x = 0; x < head.biWidth; x++){
            RGBQUAD* pClr =  &((RGBQUAD*)info.pImage)[x + y * info.dwEffWidth];
            pClr->rgbReserved = *(src + x);
        }
		//memcpy(dst,src,head.biWidth);
		//dst += head.biWidth;
		src += from.info.dwEffWidth;
	}
	return true;
}