本文整理汇总了C++中ImgFile_Ptr::ReleaseImgFileHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ ImgFile_Ptr::ReleaseImgFileHandle方法的具体用法?C++ ImgFile_Ptr::ReleaseImgFileHandle怎么用?C++ ImgFile_Ptr::ReleaseImgFileHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImgFile_Ptr
的用法示例。
在下文中一共展示了ImgFile_Ptr::ReleaseImgFileHandle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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 );
//.........这里部分代码省略.........
示例3: 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;
}
示例4: 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;
}