本文整理汇总了C++中ImgFile_Ptr::DoImgFileHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ ImgFile_Ptr::DoImgFileHandle方法的具体用法?C++ ImgFile_Ptr::DoImgFileHandle怎么用?C++ ImgFile_Ptr::DoImgFileHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImgFile_Ptr
的用法示例。
在下文中一共展示了ImgFile_Ptr::DoImgFileHandle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
bool E_ColorReverse::Init(ImgFile_Ptr pFile)
{
IImgLayer_weakPtr _sl = pFile->GetSelectLayer();
if (_sl.expired()) {
OutputError::Alert(IE_ERROR_SELECT_LAYER_DONT_EXIST);
return false;
}
IImgLayer_Ptr sl = _sl.lock();
if (sl->GetLayerType() != IE_LAYER_TYPE::NORMAL_LAYER) {
OutputError::Alert(IE_ERROR_CANT_EDIT_LAYER);
return false;
}
m_pEditLayer = std::dynamic_pointer_cast<ImgLayer>(sl);
RECT rect, mask_rect;
m_pEditLayer->GetLayerRect(&rect);
//マスクの範囲取得
if (pFile->GetMaskState() == IE_MASK_STATE_ID::INVALID) {
m_mask = NULL;
}
else {
pFile->GetMaskRect(&mask_rect);
//範囲を計算
AndRect(&rect, &mask_rect, &rect);
//マスク切り出し
IplImage* tmp_mask = cvCreateImage(
cvSize(rect.right - rect.left, rect.bottom - rect.top),
IPL_DEPTH_8U,
1);
pFile->CopyFileMask(
rect.left,
rect.top,
rect.right - rect.left,
rect.bottom - rect.top,
tmp_mask,
0, 0);
m_mask = tmp_mask;
}
CvSize sizeOfImage;
sizeOfImage.width = rect.right - rect.left;
sizeOfImage.height = rect.bottom - rect.top;
m_pEditLayerHandle = (EditLayerHandle*)pFile->CreateImgFileHandle( IFH_EDIT_LAYER );
m_pEditLayerHandle->SetHandleName( DISPLAY_NAME );
pFile->DoImgFileHandle( m_pEditLayerHandle );
m_pEditNode = m_pEditLayerHandle->CreateEditNode(&rect);
m_pEditNode->blt_rect = rect;
return true;
}
示例2: IEIO_LoadImgFile
IEIO_EXPORT bool IEIO_LoadImgFile(
const char* filePath,
ImgFile_Ptr pFile)
{
if(filePath == NULL) return NULL;
FILE* fp;
errno_t err;
//if(err = fopen_s(&fp, filePath, "rb") != 0){
if(!(fp = fopen(filePath, "rb"))){
char str[256];
int last_err = GetLastError();
sprintf(str, "PSDファイルの読み込みに失敗しました。 %s err = %d lasterror = %d", filePath, last_err);
OutputError::Alert(str);
return false;
}
//read psd header
PsdHeader header;
if(!read_psd_header(fp, pFile, &header)){
fclose(fp);
return false;
}
//
if(!read_psd_color_mode_data(fp, pFile)){
fclose(fp);
return false;
}
//
if(!read_psd_image_resource(fp, pFile)){
fclose(fp);
return false;
}
//
if(!read_psd_layer_and_mask(fp, pFile, &header)){
fclose(fp);
return false;
}
//
if(pFile->GetLayerSize() == 0){
if(!read_psd_merged_image(fp, pFile, &header)){
fclose(fp);
return false;
}
}
fclose(fp);
//
NullHandle* null_handle = (NullHandle*) pFile->CreateImgFileHandle(IFH_NULL);
strcpy_s(null_handle->handle_name, MAX_IMG_FILE_HANDLE_NAME, "PSDファイル読み込み");
pFile->DoImgFileHandle( null_handle );
return true;
}
示例3: Init
bool E_LaughingMan::Init(ImgFile_Ptr pFile)
{
m_faces = NULL;
IImgLayer_weakPtr _sl = pFile->GetSelectLayer();
if(!_sl.expired()){
OutputError::Alert(IE_ERROR_SELECT_LAYER_DONT_EXIST);
return false;
}
IImgLayer_Ptr sl = _sl.lock();
if(sl->GetLayerType() != IE_LAYER_TYPE::NORMAL_LAYER){
OutputError::Alert(IE_ERROR_CANT_EDIT_LAYER);
return false;
}
m_pEditLayer = std::dynamic_pointer_cast<ImgLayer>(sl);
RECT rect, mask_rect;
m_pEditLayer->GetLayerRect(&rect);
//マスクの範囲取得
if(pFile->GetMaskState() != IE_MASK_STATE_ID::INVALID){
pFile->GetMaskRect(&mask_rect);
//範囲を計算
AndRect(&rect, &mask_rect, &rect);
}
CvSize sizeOfImage;
sizeOfImage.width = rect.right - rect.left;
sizeOfImage.height = rect.bottom - rect.top;
m_pEditLayerHandle = (EditLayerHandle*)pFile->CreateImgFileHandle( IFH_EDIT_LAYER );
m_pEditLayerHandle->SetHandleName( DISPLAY_NAME );
pFile->DoImgFileHandle( m_pEditLayerHandle );
m_pEditNode = m_pEditLayerHandle->CreateEditNode(&rect);
m_pEditNode->blt_rect = rect;
IplImage* bgraImg;
IplImage* editImg;
IplImage* grayImg;
IplImage* editedImg;
bgraImg = cvCreateImage(
cvSize(rect.right - rect.left, rect.bottom - rect.top),
IPL_DEPTH_8U,
4);
editImg = cvCreateImage(
cvSize(rect.right - rect.left, rect.bottom - rect.top),
IPL_DEPTH_8U,
3);
grayImg = cvCreateImage(
cvSize(rect.right - rect.left, rect.bottom - rect.top),
IPL_DEPTH_8U,
1);
editedImg = cvCreateImage(
cvSize(rect.right - rect.left, rect.bottom - rect.top),
IPL_DEPTH_8U,
3);
//レイヤーから有効範囲部分のデータを取得
m_pEditLayer->CopyLayerImage(
bgraImg,
0,
0,
rect.left,
rect.top,
rect.right - rect.left,
rect.bottom - rect.top);
ucvCvtColor(bgraImg, editImg, CV_BGRA2BGR);
cvCvtColor(editImg, grayImg, CV_BGRA2GRAY);
cvEqualizeHist(grayImg, grayImg);
m_cascade = (CvHaarClassifierCascade*)cvLoad(CASCADE_FILE_PATH, 0, 0, 0);
if (m_cascade == NULL) {
return false;
}
m_storage = cvCreateMemStorage(0);;
cvClearMemStorage(m_storage);
m_faces = cvHaarDetectObjects(grayImg, m_cascade, m_storage,
1.1, 2, 0,//CV_HAAR_DO_CANNY_PRUNING,
cvSize(30, 30) );
cvReleaseImage(&bgraImg);
cvReleaseImage(&editImg);
cvReleaseImage(&grayImg);
cvReleaseImage(&editedImg);
return true;
}