本文整理汇总了C++中ImgFile_Ptr::CreateImgFileHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ ImgFile_Ptr::CreateImgFileHandle方法的具体用法?C++ ImgFile_Ptr::CreateImgFileHandle怎么用?C++ ImgFile_Ptr::CreateImgFileHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImgFile_Ptr
的用法示例。
在下文中一共展示了ImgFile_Ptr::CreateImgFileHandle方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: read_mask_pixels
static bool read_mask_pixels(
FILE* fp,
PsdLayerData* pLayerData,
ImgFile_Ptr pFile,
ImgLayerGroup_Ptr pLayerGroup)
{
int i,j;
AddNewLayerHandle* handle = (AddNewLayerHandle*)pFile->CreateImgFileHandle(IFH_ADD_NEW_LAYER );
handle->SetNewLayerRect(&(pLayerData->rect));
handle->Do( pFile );
ImgLayer_Ptr new_layer = handle->GetNewLayer().lock();
pFile->ReleaseImgFileHandle(handle);
handle = NULL;
//set blend forurCC
new_layer->SetLayerSynthFourCC( LayerSynthesizerMG::GetAlphaMaskLayerSynthFourCC() );
pFile->SetSelectLayer( new_layer );
//set name
char mask_name[MAX_IMG_LAYER_NAME + 32];
sprintf(mask_name, "%s マスク", pLayerData->name);
new_layer->SetName( mask_name );
int c_width = pLayerData->rect.right - pLayerData->rect.left;
int c_height = pLayerData->rect.bottom - pLayerData->rect.top;
IplImage* channel;
IplImage* alpha;
channel = cvCreateImage(cvSize(c_width, c_height), IPL_DEPTH_8U, 1);
alpha = cvCreateImage(cvSize(c_width, c_height), IPL_DEPTH_8U, 1);
if(!read_channel_pixels(fp, channel, c_width, c_height, pLayerData->depth, false)){
return false;
}
//set alpha channel
cvSet(alpha, cvScalar(255));
new_layer->Merge(
pLayerData->rect.left,
pLayerData->rect.top,
pLayerData->rect.right - pLayerData->rect.left,
pLayerData->rect.bottom - pLayerData->rect.top,
channel,
channel,
channel,
alpha);
LPUPDATE_DATA pData = new_layer->CreateUpdateData();
pData->isAll = true;
new_layer->PushUpdateData( pData );
return true;
}
示例4: 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;
}
示例5: read_psd_merged_image
static bool read_psd_merged_image(
FILE* fp,
ImgFile_Ptr pFile,
PsdHeader* header)
{
int i,j,k;
AddNewLayerHandle* handle = (AddNewLayerHandle*)pFile->CreateImgFileHandle(IFH_ADD_NEW_LAYER );
handle->Do( pFile );
ImgLayer_Ptr new_layer = handle->GetNewLayer().lock();
pFile->ReleaseImgFileHandle(handle);
handle = NULL;
pFile->SetSelectLayer( new_layer );
IplImage* channels[4];
for(i=0; i<4; i++){
channels[i] = cvCreateImage(cvSize(header->col, header->row), IPL_DEPTH_8U, 1);
}
int bytes_per_pixel = header->depth / 8;
int bytes_per_row = header->col * bytes_per_pixel;
int total_bytes = bytes_per_row * header->row;
int extra_channels;
switch(header->mode){
case PSD_COLOR_MODE_RGB:
extra_channels = header->channels - 3;
}
uint16_t** rle_pack_len = (uint16_t**) malloc(sizeof(uint16_t*) * header->channels);
memset(rle_pack_len, 0, sizeof(uint16_t*) * header->channels);
uint16_t compression = read_2byte_BE(fp);
switch(compression){
case PSD_CM_NONE:
{
for(i=0; i<header->channels; i++){
uint8_t* dst = GetPixelAddress(channels[i], 0, 0);
if(!fread(dst, total_bytes, 1, fp)){
return false;
}
}
}
break;
case PSD_CM_RLE:
{
for(i=0; i<header->channels; i++){
rle_pack_len[i] = (uint16_t*) malloc(sizeof(uint16_t) * header->row);
for(j=0; j<header->row; j++){
rle_pack_len[i][j] = read_2byte_BE(fp);
}
}
for(i=0; i<header->channels; i++){
for(j=0; j<header->row; j++){
uint8_t* src = (uint8_t*) malloc(rle_pack_len[i][j]);
uint8_t* dst = GetPixelAddress(channels[i], 0, j);
if(!fread(src, rle_pack_len[i][j], 1, fp)){
return false;
}
decode_rle((int8_t*)src, rle_pack_len[i][j], bytes_per_row, (int8_t*)dst);
free(src);
}
}
}
break;
}
if(rle_pack_len){
for(i=0; i<header->channels; i++){
if(rle_pack_len[i]){
free(rle_pack_len[i]);
}
}
free(rle_pack_len);
}
if(header->channels == 3){
//set alpha channel
cvSet(channels[3], cvScalar(255));
}
new_layer->Merge(
0, 0,
header->col,
header->row,
channels[2],
channels[1],
channels[0],
channels[3]);
LPUPDATE_DATA pData = new_layer->CreateUpdateData();
pData->isAll = true;
new_layer->PushUpdateData( pData );
//.........这里部分代码省略.........
示例6: read_psd_layer_group
static bool read_psd_layer_group(
FILE* fp,
int layer_num,
PsdLayerData* psd_layers,
int* layer_index,
ImgFile_Ptr pFile,
ImgLayerGroup_Ptr pLayerGroup)
{
if((*layer_index) >= layer_num)
return true;
for(; (*layer_index)<layer_num; (*layer_index)++){
switch(psd_layers[ (*layer_index) ].layer_type){
case PSD_LAYER_TYPE::PSD_NORMAL_LAYER:
if(!read_layer_pixels(fp, &psd_layers[ (*layer_index) ], pFile, pLayerGroup)){
return false;
}
if(psd_layers[ (*layer_index) ].is_mask){
if(!read_mask_pixels(fp, &psd_layers[ (*layer_index) ], pFile, pLayerGroup)){
return false;
}
}
break;
case PSD_LAYER_TYPE::PSD_GROUP_LAYER:
{
int j;
uint16_t compression;
for(j=0; j<psd_layers[ (*layer_index) ].channel_num; j++){
psd_layers[ (*layer_index) ].psd_channels[j].data_length;
compression = read_2byte_BE(fp);
}
//
pLayerGroup->SetName( psd_layers[ (*layer_index) ].name );
}
return true; //finish read layer
case PSD_LAYER_TYPE::PSD_CLOSE_GROUP_LAYER:
{
int j;
uint16_t compression;
for(j=0; j<psd_layers[ (*layer_index) ].channel_num; j++){
psd_layers[ (*layer_index) ].psd_channels[j].data_length;
compression = read_2byte_BE(fp);
}
(*layer_index)++;
//create new layer group
AddNewLayerGroupHandle* handle = (AddNewLayerGroupHandle*)pFile->CreateImgFileHandle(IFH_ADD_NEW_LAYER_GROUP );
handle->Do( pFile );
read_psd_layer_group(
fp,
layer_num,
psd_layers,
layer_index,
pFile,
handle->GetNewLayeyGroup().lock());
pFile->SetSelectLayer( pLayerGroup );
pFile->ReleaseImgFileHandle(handle);
handle = NULL;
}
break;
}
}
return true;
}
示例7: read_layer_pixels
static bool read_layer_pixels(
FILE* fp,
PsdLayerData* pLayerData,
ImgFile_Ptr pFile,
ImgLayerGroup_Ptr pLayerGroup)
{
int i,j;
//create new layer
AddNewLayerHandle* handle = (AddNewLayerHandle*)pFile->CreateImgFileHandle(IFH_ADD_NEW_LAYER );
handle->SetNewLayerRect(&(pLayerData->rect));
handle->Do( pFile );
ImgLayer_Ptr new_layer = handle->GetNewLayer().lock();
pFile->ReleaseImgFileHandle(handle);
handle = NULL;
//set layer synthesizer
new_layer->SetLayerSynthFourCC( pLayerData->blend_fourcc );
//set layer opacity
new_layer->SetOpacity( pLayerData->opacity );
pFile->SetSelectLayer( new_layer );
//
new_layer->SetName( pLayerData->name );
new_layer->ExtendLayer(); //不足分があれば拡張
IplImage* channels[4];
CvSize size = cvSize(
pLayerData->rect.right - pLayerData->rect.left,
pLayerData->rect.bottom - pLayerData->rect.top);
for(i=0; i<4; i++){
channels[i] = cvCreateImage(size, IPL_DEPTH_8U, 1);
}
int c_width = pLayerData->rect.right - pLayerData->rect.left;
int c_height = pLayerData->rect.bottom - pLayerData->rect.top;
for(i=0; i<pLayerData->channel_num; i++){
int cn=0;
int16_t id = pLayerData->psd_channels[i].id;
if(id == PSD_CHANNEL_MASK){
read_mask_pixels(fp, pLayerData, pFile, pLayerGroup);
pLayerData->is_mask = false;
break;
}
switch(id){
case PSD_CHANNEL_RED:
cn = 2;
break;
case PSD_CHANNEL_GREEN:
cn = 1;
break;
case PSD_CHANNEL_BLUE:
cn = 0;
break;
case PSD_CHANNEL_ALPHA:
cn = 3;
break;
}
if(!read_channel_pixels(
fp,
channels[cn],
c_width,
c_height,
pLayerData->depth,
false))
{
return false;
}
}
if(pLayerData->channel_num == 3){
//set alpha channel
cvSet(channels[3], cvScalar(255));
}
new_layer->Merge(
pLayerData->rect.left,
pLayerData->rect.top,
pLayerData->rect.right - pLayerData->rect.left,
pLayerData->rect.bottom - pLayerData->rect.top,
channels[0],
channels[1],
channels[2],
channels[3]);
LPUPDATE_DATA pData = new_layer->CreateUpdateData();
pData->isAll = true;
new_layer->PushUpdateData( pData );
cvReleaseImage( &channels[0] );
cvReleaseImage( &channels[1] );
cvReleaseImage( &channels[2] );
cvReleaseImage( &channels[3] );
return true;
}