本文整理汇总了C++中LibRaw::raw2image方法的典型用法代码示例。如果您正苦于以下问题:C++ LibRaw::raw2image方法的具体用法?C++ LibRaw::raw2image怎么用?C++ LibRaw::raw2image使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LibRaw
的用法示例。
在下文中一共展示了LibRaw::raw2image方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extractRAWData
bool KDcraw::extractRAWData(const QString& filePath, QByteArray& rawData, DcrawInfoContainer& identify, unsigned int shotSelect)
{
QFileInfo fileInfo(filePath);
QString rawFilesExt(rawFiles());
QString ext = fileInfo.suffix().toUpper();
identify.isDecodable = false;
if (!fileInfo.exists() || ext.isEmpty() || !rawFilesExt.toUpper().contains(ext))
return false;
if (m_cancel)
return false;
d->setProgress(0.1);
LibRaw raw;
// Set progress call back function.
raw.set_progress_handler(callbackForLibRaw, d);
int ret = raw.open_file((const char*)(QFile::encodeName(filePath)).constData());
if (ret != LIBRAW_SUCCESS)
{
qCDebug(LIBKDCRAW_LOG) << "LibRaw: failed to run open_file: " << libraw_strerror(ret);
raw.recycle();
return false;
}
if (m_cancel)
{
raw.recycle();
return false;
}
d->setProgress(0.3);
raw.imgdata.params.output_bps = 16;
raw.imgdata.params.shot_select = shotSelect;
ret = raw.unpack();
if (ret != LIBRAW_SUCCESS)
{
qCDebug(LIBKDCRAW_LOG) << "LibRaw: failed to run unpack: " << libraw_strerror(ret);
raw.recycle();
return false;
}
if (m_cancel)
{
raw.recycle();
return false;
}
d->setProgress(0.4);
ret = raw.raw2image();
if (ret != LIBRAW_SUCCESS)
{
qCDebug(LIBKDCRAW_LOG) << "LibRaw: failed to run raw2image: " << libraw_strerror(ret);
raw.recycle();
return false;
}
if (m_cancel)
{
raw.recycle();
return false;
}
d->setProgress(0.6);
Private::fillIndentifyInfo(&raw, identify);
if (m_cancel)
{
raw.recycle();
return false;
}
d->setProgress(0.8);
rawData = QByteArray();
if (raw.imgdata.idata.filters == 0)
{
rawData.resize((int)(raw.imgdata.sizes.iwidth * raw.imgdata.sizes.iheight * raw.imgdata.idata.colors * sizeof(unsigned short)));
unsigned short* output = reinterpret_cast<unsigned short*>(rawData.data());
for (unsigned int row = 0; row < raw.imgdata.sizes.iheight; row++)
{
for (unsigned int col = 0; col < raw.imgdata.sizes.iwidth; col++)
{
for (int color = 0; color < raw.imgdata.idata.colors; color++)
{
*output = raw.imgdata.image[raw.imgdata.sizes.iwidth*row + col][color];
output++;
}
}
//.........这里部分代码省略.........
示例2: main
int main(int ac, char *av[])
{
int i, ret;
int autoscale=0,black_subtraction=1, use_gamma=0;
char outfn[1024];
LibRaw RawProcessor;
if(ac<2)
{
usage:
printf(
"4channeld - LibRaw %s sample. %d cameras supported\n"
"Usage: %s [-s N] [-g] [-A] [-B] [-N] raw-files....\n"
"\t-s N - select Nth image in file (default=0)\n"
"\t-g - use gamma correction with gamma 2.2 (not precise,use for visual inspection only)\n"
"\t-A - autoscaling (by integer factor)\n"
"\t-B - no black subtraction\n"
,LibRaw::version(),
LibRaw::cameraCount(),
av[0]);
return 0;
}
#define P1 RawProcessor.imgdata.idata
#define S RawProcessor.imgdata.sizes
#define C RawProcessor.imgdata.color
#define T RawProcessor.imgdata.thumbnail
#define P2 RawProcessor.imgdata.other
#define OUT RawProcessor.imgdata.params
OUT.document_mode=2;
OUT.output_bps=16;
OUT.output_tiff=1;
OUT.user_flip=0;
OUT.no_auto_bright = 1;
OUT.half_size=1;
for (i=1;i<ac;i++)
{
if(av[i][0]=='-')
{
if(av[i][1]=='s' && av[i][2]==0)
{
i++;
OUT.shot_select=atoi(av[i]);
}
else if(av[i][1]=='g' && av[i][2]==0)
use_gamma = 1;
else if(av[i][1]=='A' && av[i][2]==0)
autoscale=1;
else if(av[i][1]=='B' && av[i][2]==0)
{
black_subtraction=0;
}
else
goto usage;
continue;
}
if(!use_gamma)
OUT.gamm[0] = OUT.gamm[1] = 1;
int c;
printf("Processing file %s\n",av[i]);
if( (ret = RawProcessor.open_file(av[i])) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot open %s: %s\n",av[i],libraw_strerror(ret));
continue; // no recycle b/c open file will recycle itself
}
if(P1.is_foveon)
{
printf("Cannot process Foveon image %s\n",av[i]);
continue ;
}
if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot unpack %s: %s\n",av[i],libraw_strerror(ret));
continue;
}
RawProcessor.raw2image();
if(black_subtraction)
{
RawProcessor.subtract_black();
}
if(autoscale)
{
unsigned max=0,scale=1;
for(int j=0; j<S.iheight*S.iwidth; j++)
for(int c = 0; c< 4; c++)
if(max < RawProcessor.imgdata.image[j][c])
max = RawProcessor.imgdata.image[j][c];
if (max >0 && max< 1<<15)
{
scale = (1<<16)/max;
printf("Scaling with multiplier=%d (max=%d)\n",scale,max);
for(int j=0; j<S.iheight*S.iwidth; j++)
for(c=0;c<4;c++)
RawProcessor.imgdata.image[j][c] *= scale;
}
printf("Black level (scaled)=%d\n",C.black*scale);
//.........这里部分代码省略.........
示例3:
int libraw_raw2image(libraw_data_t* lr)
{
if(!lr) return EINVAL;
LibRaw *ip = (LibRaw*) lr->parent_class;
return ip->raw2image();
}
示例4: try_reading_file_with_libraw_4channels
// reads the RAW and builds a 4 channel image
int try_reading_file_with_libraw_4channels(const char *fname, struct iio_image *x)
{
int ret;
int verbose=0;
int shot_select = 0;
LibRaw RawProcessor;
#define S RawProcessor.imgdata.sizes
#define OUT RawProcessor.imgdata.params
//
//OUT.shot_select=shot_selected;
if(verbose) fprintf(stderr,"LIBRAW: Processing file %s\n",fname);
if( (ret = RawProcessor.open_file(fname)) != LIBRAW_SUCCESS)
{
if(verbose) fprintf(stderr,"LIBRAW: Cannot open %s: %s\n",fname,libraw_strerror(ret));
return 0; // no recycle b/c open file will recycle itself
}
if(RawProcessor.imgdata.idata.is_foveon)
{
if(verbose) fprintf(stderr,"LIBRAW: Cannot process Foveon image %s\n",fname);
return 0;
}
if(verbose)
{
fprintf(stderr,"LIBRAW: Image size: %dx%d\nRaw size: %dx%d\n",S.width,S.height,S.raw_width,S.raw_height);
fprintf(stderr,"LIBRAW: Margins: top=%d, left=%d\n",
S.top_margin,S.left_margin);
}
if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
{
if(verbose) fprintf(stderr,"LIBRAW: Cannot unpack %s: %s\n",fname,libraw_strerror(ret));
return 0;
}
if(verbose)
fprintf(stderr,"LIBRAW: Unpacked....\n");
if(!(RawProcessor.imgdata.idata.filters || RawProcessor.imgdata.idata.colors == 1))
{
if(verbose) fprintf(stderr,"LIBRAW: Only Bayer-pattern RAW files supported, sorry....\n");
return 0;
}
RawProcessor.raw2image();
RawProcessor.imgdata.idata.colors = 1;
S.width = S.iwidth;
S.height = S.iheight;
x->type = 3; //IIO_TYPE_INT16;
x->pixel_dimension = 4;
x->dimension = 2;
x->format = 0; //IIO_FORMAT_WHATEVER;
x->contiguous_data = false;
//bool caca[3];
x->sizes[0] = S.iwidth/2;
x->sizes[1] = S.iheight/2;
x->data = (void*) malloc(sizeof(uint16_t)*S.iwidth/2 * S.iheight/2 * 4);
uint16_t * odata = (uint16_t*)x->data;
int ncout = S.iwidth/2;
int color[] = {0,1,3,2};
for (int j=0; j<2; j++)
for (int i=0; i<2; i++)
for (int rr = 0; rr < S.iheight/2; rr++)
for (int rc = 0; rc < S.iwidth/2; rc++) {
odata[(rr*S.iwidth/2 + rc)*4 +color[i+2*j]] =
RawProcessor.imgdata.image[(2*rr+j)*S.iwidth + 2*rc+i][color[i+2*j]];
}
if(verbose) fprintf(stderr,"LIBRAW: Sent to IIO\n");
return 1;
}