本文整理汇总了C++中pm_error函数的典型用法代码示例。如果您正苦于以下问题:C++ pm_error函数的具体用法?C++ pm_error怎么用?C++ pm_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pm_error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int
main(int argc,
char * argv[]) {
FILE * ifP;
unsigned char * bitrow;
unsigned int rows, cols, depth;
unsigned int padright;
unsigned int row;
unsigned int itemCount;
const char * inputFileName;
pbm_init(&argc, argv);
if (argc-1 > 1)
pm_error("Too many arguments (%u). "
"Only argument is optional input file", argc-1);
if (argc-1 == 1)
inputFileName = argv[1];
else
inputFileName = "-";
ifP = pm_openr(inputFileName);
readMgrHeader(ifP, &cols, &rows, &depth, &padright);
if (depth != 1)
pm_error("MGR file has depth of %u, must be 1", depth);
pbm_writepbminit(stdout, cols, rows, 0);
bitrow = pbm_allocrow_packed(cols + padright);
itemCount = (cols + padright ) / 8;
for (row = 0; row < rows; ++row) {
/* The raster formats are nearly identical.
MGR may have rows padded to 16 or 32 bit boundaries.
*/
size_t bytesRead;
bytesRead = fread(bitrow, 1, itemCount, ifP);
if (bytesRead < itemCount)
pm_error("fread() failed to read mgr bitmap data");
pbm_writepbmrow_packed(stdout, bitrow, cols, 0);
}
pm_close(ifP);
pm_close(stdout);
return 0;
}
开发者ID:Eleanor66613,项目名称:CS131,代码行数:49,代码来源:mgrtopbm.c
示例2: parseCommandLine
static void
parseCommandLine(int argc,
char ** argv,
struct cmdlineInfo *cmdlineP ) {
/*----------------------------------------------------------------------------
Parse program command line described in Unix standard form by argc
and argv. Return the information in the options as *cmdlineP.
If command line is internally inconsistent (invalid options, etc.),
issue error message to stderr and abort program.
Note that the strings we return are stored in the storage that
was passed to us as the argv array. We also trash *argv.
-----------------------------------------------------------------------------*/
optEntry *option_def = malloc(100*sizeof(optEntry));
/* Instructions to pm_optParseOptions3 on how to parse our options.
*/
optStruct3 opt;
unsigned int option_def_index;
option_def_index = 0; /* incremented by OPTENT3 */
OPTENT3(0, "ccir601", OPT_FLAG, NULL,
&cmdlineP->ccir601, 0);
opt.opt_table = option_def;
opt.short_allowed = FALSE; /* We have no short (old-fashioned) options */
opt.allowNegNum = FALSE; /* We have no parms that are negative numbers */
pm_optParseOptions3( &argc, argv, opt, sizeof(opt), 0);
/* Uses and sets argc, argv, and some of *cmdlineP and others. */
if (argc-1 !=3)
pm_error("You must specify 3 arguments. "
"You specified %d", argc-1);
else {
int width, height;
cmdlineP->filenameBase = argv[1];
width = atoi(argv[2]);
if (width < 1)
pm_error("Width must be at least 1. You specified %d", width);
height = atoi(argv[3]);
if (height < 1)
pm_error("Height must be at least 1. You specified %d", height);
cmdlineP->width = width;
cmdlineP->height = height;
}
}
开发者ID:chneukirchen,项目名称:netpbm-mirror,代码行数:49,代码来源:yuvsplittoppm.c
示例3: getGrayComponent
static void
getGrayComponent(int * jasperCmptP, jas_image_t * const jasperP) {
int const rc =
jas_image_getcmptbytype(jasperP,
JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_GRAY_Y));
if (rc < 0)
pm_error("Input says it has Grayscale color space, but contains "
"no gray intensity component");
else
*jasperCmptP = rc;
if (jas_image_cmptsgnd(jasperP, 0))
pm_error("Input image says it is grayscale, but has signed values "
"for what should be the gray levels.");
}
开发者ID:Eleanor66613,项目名称:CS131,代码行数:15,代码来源:jpeg2ktopam.c
示例4: rejectOutOfBounds
static void
rejectOutOfBounds(unsigned int const cols,
unsigned int const rows,
int const leftcol,
int const rightcol,
int const toprow,
int const bottomrow,
bool const pad) {
/* Reject coordinates off the edge */
if (!pad) {
if (leftcol < 0)
pm_error("You have specified a left edge (%d) that is beyond "
"the left edge of the image (0)", leftcol);
if (leftcol > (int)(cols-1))
pm_error("You have specified a left edge (%d) that is beyond "
"the right edge of the image (%u)", leftcol, cols-1);
if (rightcol < 0)
pm_error("You have specified a right edge (%d) that is beyond "
"the left edge of the image (0)", rightcol);
if (rightcol > (int)(cols-1))
pm_error("You have specified a right edge (%d) that is beyond "
"the right edge of the image (%u)", rightcol, cols-1);
if (toprow < 0)
pm_error("You have specified a top edge (%d) that is above "
"the top edge of the image (0)", toprow);
if (toprow > (int)(rows-1))
pm_error("You have specified a top edge (%d) that is below "
"the bottom edge of the image (%u)", toprow, rows-1);
if (bottomrow < 0)
pm_error("You have specified a bottom edge (%d) that is above "
"the top edge of the image (0)", bottomrow);
if (bottomrow > (int)(rows-1))
pm_error("You have specified a bottom edge (%d) that is below "
"the bottom edge of the image (%u)", bottomrow, rows-1);
}
if (leftcol > rightcol)
pm_error("You have specified a left edge (%d) that is to the right of "
"the right edge you specified (%d)",
leftcol, rightcol);
if (toprow > bottomrow)
pm_error("You have specified a top edge (%d) that is below "
"the bottom edge you specified (%d)",
toprow, bottomrow);
}
开发者ID:Eleanor66613,项目名称:CS131,代码行数:48,代码来源:pamcut.c
示例5: interpolate
static void
interpolate(struct pam * const pamP,
tuple * const tuplerow,
tuple const first,
tuple const last) {
unsigned int plane;
for (plane = 0; plane < pamP->depth; ++plane) {
int const spread = last[plane] - first[plane];
int col;
if (INT_MAX / pamP->width < abs(spread))
pm_error("Arithmetic overflow. You must reduce the width of "
"the image (now %u) or the range of color values "
"(%u in plane %u) so that their "
"product is less than %d",
pamP->width, abs(spread), plane, INT_MAX);
for (col = 0; col < pamP->width; ++col)
tuplerow[col][plane] =
first[plane] + (spread * col / (int)pamP->width);
}
}
开发者ID:jhbsz,项目名称:DIR-850L_A1,代码行数:25,代码来源:pamgradient.c
示例6: createTiffGenerator
static void
createTiffGenerator(int const ofd,
const char * const outFileName,
bool const append,
TIFF ** const tifPP) {
const char * option;
/* Before 10.12 (November 2002), we set O_NONBLOCK here:
fcntl( 1, F_SETFL, O_NONBLOCK ) ;
I have no idea why. The comment attached said,
acooke dec99 - otherwise blocks on read inside
next line (Linux i386)
*/
validateSeekableOutputFile(ofd, outFileName);
if (append)
option = "a";
else
option = "w";
*tifPP = TIFFFdOpen(ofd, outFileName, option);
if (*tifPP == NULL)
pm_error("error opening standard output as TIFF file. "
"TIFFFdOpen() failed.");
}
开发者ID:moseymosey,项目名称:netpbm,代码行数:30,代码来源:pamtotiff.c
示例7: computeColorSpace
static enum colorspace
computeColorSpace(struct jpeg_decompress_struct * const cinfoP,
enum inklevel const inklevel) {
enum colorspace colorSpace;
if (cinfoP->out_color_space == JCS_GRAYSCALE)
colorSpace = GRAYSCALE_COLORSPACE;
else if (cinfoP->out_color_space == JCS_RGB)
colorSpace = RGB_COLORSPACE;
else if (cinfoP->out_color_space == JCS_CMYK) {
switch (inklevel) {
case ADOBE:
colorSpace = CMYK_ADOBE_COLORSPACE; break;
case NORMAL:
colorSpace = CMYK_NORMAL_COLORSPACE; break;
case GUESS:
colorSpace = CMYK_ADOBE_COLORSPACE; break;
}
} else
pm_error("Internal error: unacceptable output color space from "
"JPEG decompressor.");
return colorSpace;
}
开发者ID:Eleanor66613,项目名称:CS131,代码行数:25,代码来源:jpegtopnm.c
示例8: main
int
main(int argc, const char ** argv) {
FILE * ifP;
struct CmdlineInfo cmdline;
struct SbigHeader hdr;
pm_proginit(&argc, argv);
parseCommandLine(argc, argv, &cmdline);
ifP = pm_openr(cmdline.inputFileName);
readSbigHeader(ifP, &hdr);
pm_message("SBIG '%s' %ux%u %s image, saturation level = %u",
(hdr.haveCameraType ? hdr.cameraType : "ST-?"),
hdr.cols, hdr.rows,
hdr.isCompressed ? "compressed" : "uncompressed",
hdr.maxval);
if (hdr.maxval > PGM_OVERALLMAXVAL) {
pm_error("Saturation level (%u levels) is too large"
"This program's limit is %u.", hdr.maxval, PGM_OVERALLMAXVAL);
}
pgm_writepgminit(stdout, hdr.cols, hdr.rows, hdr.maxval, 0);
writeRaster(ifP, hdr, stdout);
pm_close(ifP);
pm_close(stdout);
return 0;
}
开发者ID:chneukirchen,项目名称:netpbm-mirror,代码行数:35,代码来源:sbigtopgm.c
示例9: readPpmPalette
static void
readPpmPalette(const char * const paletteFileName,
pixel (* const ppmPaletteP)[],
unsigned int * const paletteSizeP) {
FILE * pfP;
pixel ** pixels;
int cols, rows;
pixval maxval;
pfP = pm_openr(paletteFileName);
pixels = ppm_readppm(pfP, &cols, &rows, &maxval);
pm_close(pfP);
*paletteSizeP = rows * cols;
if (*paletteSizeP > MAXCOLORS)
pm_error("ordered palette image contains %d pixels. Maximum is %d",
*paletteSizeP, MAXCOLORS);
{
int j;
int row;
j = 0; /* initial value */
for (row = 0; row < rows; ++row) {
int col;
for (col = 0; col < cols; ++col)
(*ppmPaletteP)[j++] = pixels[row][col];
}
}
ppm_freearray(pixels, rows);
}
开发者ID:Eleanor66613,项目名称:CS131,代码行数:33,代码来源:ppmtopcx.c
示例10: makePfmHeader
static struct pfmHeader
makePfmHeader(const struct pam * const pamP,
float const scaleFactor,
enum endian const endian) {
struct pfmHeader pfmHeader;
pfmHeader.width = pamP->width;
pfmHeader.height = pamP->height;
if (strncmp(pamP->tuple_type, "RGB", 3) == 0)
pfmHeader.color = TRUE;
else if (strncmp(pamP->tuple_type, "GRAYSCALE", 9) == 0)
pfmHeader.color = FALSE;
else if (strncmp(pamP->tuple_type, "BLACKANDWHITE", 13) == 0)
pfmHeader.color = FALSE;
else
pm_error("Invalid PAM input. Tuple type is '%s'. "
"We understand only RGB* and GRAYSCALE*", pamP->tuple_type);
pfmHeader.scaleFactor = scaleFactor;
pfmHeader.endian = endian;
return pfmHeader;
}
开发者ID:gguillotte,项目名称:netpbm-code,代码行数:25,代码来源:pamtopfm.c
示例11: createPipeFeeder
static void
createPipeFeeder(void pipeFeederRtn(int, void *),
void * const feederParm,
int * const fdP,
pid_t * const pidP) {
/*----------------------------------------------------------------------------
Create a process and a pipe. Have the process run program
'pipeFeederRtn' to fill the pipe and return the file descriptor of the
other end of the pipe as *fdP.
-----------------------------------------------------------------------------*/
int pipeToFeed[2];
pid_t feederPid;
pipe(pipeToFeed);
feederPid = fork();
if (feederPid < 0) {
pm_error("fork() of stdin feeder failed. errno=%d (%s)",
errno, strerror(errno));
} else if (feederPid == 0) {
/* This is the child -- the stdin feeder process */
close(pipeToFeed[0]);
(*pipeFeederRtn)(pipeToFeed[1], feederParm);
exit(0);
}
else {
/* This is the parent */
close(pipeToFeed[1]);
*fdP = pipeToFeed[0];
*pidP = feederPid;
}
}
开发者ID:moseymosey,项目名称:netpbm,代码行数:31,代码来源:libsystem.c
示例12: dsCreateSource
struct sourceManager *
dsCreateSource(const char * const fileName) {
struct sourceManager * srcP;
MALLOCVAR(srcP);
if (srcP == NULL)
pm_error("Unable to get memory for the Jpeg library source manager.");
srcP->ifP = pm_openr(fileName);
srcP->jpegSourceMgr.init_source = dsInitSource;
srcP->jpegSourceMgr.fill_input_buffer = dsFillInputBuffer;
srcP->jpegSourceMgr.skip_input_data = dsSkipInputData;
srcP->jpegSourceMgr.resync_to_restart = jpeg_resync_to_restart;
srcP->jpegSourceMgr.term_source = dsTermSource;
srcP->prematureEof = FALSE;
srcP->currentBuffer = srcP->buffer1;
srcP->nextBuffer = srcP->buffer2;
srcP->jpegSourceMgr.bytes_in_buffer =
fread(srcP->currentBuffer, 1, BUFFER_SIZE, srcP->ifP);
srcP->jpegSourceMgr.next_input_byte = srcP->currentBuffer;
srcP->bytesInNextBuffer =
fread(srcP->nextBuffer, 1, BUFFER_SIZE, srcP->ifP);
return srcP;
}
开发者ID:Eleanor66613,项目名称:CS131,代码行数:28,代码来源:jpegdatasource.c
示例13: cropOneImage
static void
cropOneImage(struct cmdlineInfo const cmdline,
FILE * const ifP,
FILE * const bdfP,
FILE * const ofP) {
/*----------------------------------------------------------------------------
Crop the image to which the stream *ifP is presently positioned
and write the results to *ofP. If bdfP is non-null, use the image
to which stream *bdfP is presently positioned as the borderfile
(the file that tells us where the existing borders are in the input
image). Leave *ifP and *bdfP positioned after the image.
Both files are seekable.
-----------------------------------------------------------------------------*/
xelval maxval, bmaxval;
int format, bformat;
int rows, cols, brows, bcols;
bool hasBorders;
borderSet oldBorder;
/* The sizes of the borders in the input image */
cropSet crop;
/* The crops we have to do on each side */
xel background;
pnm_readpnminit(ifP, &cols, &rows, &maxval, &format);
if (bdfP)
pnm_readpnminit(bdfP, &bcols, &brows, &bmaxval, &bformat);
if (bdfP)
analyzeImage(bdfP, bcols, brows, bmaxval, bformat, cmdline.background,
FILEPOS_END,
&background, &hasBorders, &oldBorder);
else
analyzeImage(ifP, cols, rows, maxval, format, cmdline.background,
FILEPOS_BEG,
&background, &hasBorders, &oldBorder);
if (cmdline.verbose) {
pixel const backgroundPixel = pnm_xeltopixel(background, format);
pm_message("Background color is %s",
ppm_colorname(&backgroundPixel, maxval, TRUE /*hexok*/));
}
if (!hasBorders)
pm_error("The image is entirely background; "
"there is nothing to crop.");
determineCrops(cmdline, &oldBorder, &crop);
validateComputableSize(cols, rows, crop);
if (cmdline.verbose)
reportCroppingParameters(crop);
if (PNM_FORMAT_TYPE(format) == PBM_TYPE)
writeCroppedPBM(ifP, cols, rows, format, crop, background, ofP);
else
writeCroppedNonPbm(ifP, cols, rows, maxval, format, crop,
background, ofP);
}
开发者ID:chneukirchen,项目名称:netpbm-mirror,代码行数:60,代码来源:pnmcrop.c
示例14: pnm_writepnminit
void
pnm_writepnminit(FILE * const fileP,
int const cols,
int const rows,
xelval const maxval,
int const format,
int const forceplain) {
bool const plainFormat = forceplain || pm_plain_output;
switch (PNM_FORMAT_TYPE(format)) {
case PPM_TYPE:
ppm_writeppminit(fileP, cols, rows, (pixval) maxval, plainFormat);
break;
case PGM_TYPE:
pgm_writepgminit(fileP, cols, rows, (gray) maxval, plainFormat);
break;
case PBM_TYPE:
pbm_writepbminit(fileP, cols, rows, plainFormat);
break;
default:
pm_error("invalid format argument received by pnm_writepnminit(): %d"
"PNM_FORMAT_TYPE(format) must be %d, %d, or %d",
format, PBM_TYPE, PGM_TYPE, PPM_TYPE);
}
}
开发者ID:Eleanor66613,项目名称:CS131,代码行数:29,代码来源:libpnm2.c
示例15: readICEntry
static IC_Entry
readICEntry (void)
{
IC_Entry entry;
MALLOCVAR(entry);
if (entry == NULL)
pm_error("Unable to allcoate memory for IC entry");
entry->width = readU1();
entry->height = readU1();
entry->color_count = readU1();
entry->reserved = readU1();
entry->planes = readU2();
entry->bitcount = readU2();
entry->size_in_bytes = readU4();
entry->file_offset = readU4();
entry->colors = NULL;
entry->ih = NULL;
entry->xorBitmap = NULL;
entry->andBitmap = NULL;
return entry;
}
开发者ID:jhbsz,项目名称:DIR-850L_A1,代码行数:25,代码来源:winicontoppm.c
示例16: createHist
static void
createHist(bool const colorWanted[3],
unsigned int const histWidth,
unsigned int * (* const histP)[3]) {
/*----------------------------------------------------------------------------
Allocate the histogram arrays and set each slot count to zero.
-----------------------------------------------------------------------------*/
unsigned int color;
for (color = 0; color < 3; ++color) {
if (colorWanted[color]) {
unsigned int * hist;
unsigned int i;
MALLOCARRAY(hist, histWidth);
if (hist == NULL)
pm_error("Not enough memory for histogram arrays (%u bytes)",
histWidth * (unsigned)sizeof(hist[0]) * 3);
for (i = 0; i < histWidth; ++i)
hist[i] = 0;
(*histP)[color] = hist;
} else
(*histP)[color] = NULL;
}
}
开发者ID:chneukirchen,项目名称:netpbm-mirror,代码行数:25,代码来源:pnmhistmap.c
示例17: abel
/* ----------------------------------------------------------------------------
** procedure for making the Abel integration for deconvolution of the image
** y <-> array with values for deconvolution and results
** N <- width of the array
** adl <- array with pre-calculated weighting factors
*/
static void
abel ( float *y, int N, double *adl)
{
register int n;
double *rho, *rhop; /* results and new index */
float *yp; /* new indizes for the y-array */
MALLOCARRAY(rho, N);
if( !rho )
pm_error( "out of memory" );
rhop = rho;
yp = y;
for (n=0 ; n<N ; n++)
{
*(rhop++) = ((*yp++) - Sum(n,rho,N,adl))/(adl[n*N+n]);
/* *(rhop++) = ((*yp++) - Sum(n,rho,N))/(dr(n,n+0.5,N)); old version */
if ( *rhop < 0.0 ) *rhop = 0.0; /* error correction ! */
/* if (n > 2) rhop[n-1] = (rho[n-2]+rho[n-1]+rho[n])/3.0; stabilization*/
}
for (n=0 ; n<N ; n++)
{
if (( n>=1 )&&( n<N-1 ))
(*y++) = ((rho[n-1]*0.5+rho[n]+rho[n+1]*0.5)/2.0);/*1D median filter*/
else (*y++) = rho[n];
}
free(rho);
}
开发者ID:Eleanor66613,项目名称:CS131,代码行数:34,代码来源:pgmabel.c
示例18: computeColorMap
static void
computeColorMap(struct pam * const pamP,
tuple ** const tupleArray,
unsigned int * const numColorsP,
tupletable * const colormapP,
tuplehash * const colorhashP,
bool const show) {
unsigned int numColors;
tupletable colormap;
colormap = pnm_computetuplefreqtable(pamP, tupleArray, 0, &numColors);
if (numColors > 0xFF0)
pm_error("too many colors; "
"use pnmquant to reduce to no more than %u colors", 0xFF0);
if (show) {
unsigned int colorIndex;
fprintf(stderr, "Color map:\n");
fprintf(stderr, " Index Color\n");
for (colorIndex = 0; colorIndex < numColors; ++colorIndex) {
unsigned int plane;
fprintf(stderr, " %5u ", colorIndex);
for (plane = 0; plane < pamP->depth; ++plane)
fprintf(stderr, "%3lu ", colormap[colorIndex]->tuple[plane]);
fprintf(stderr, "\n");
}
}
*colorhashP = pnm_computetupletablehash(pamP, colormap, numColors);
*numColorsP = numColors;
*colormapP = colormap;
}
开发者ID:cjd8363,项目名称:Global-Illum,代码行数:34,代码来源:pamtodjvurle.c
示例19: main
int
main(int argc, char **argv) {
struct cmdlineInfo cmdline;
FILE * ifP;
tuplen ** tuplenarray;
struct pam inpam;
double sharpness;
pnm_init(&argc, argv);
parseCommandLine(argc, argv, &cmdline);
ifP = pm_openr(cmdline.inputFilespec);
tuplenarray = pnm_readpamn(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type));
if (inpam.height < 3 || inpam.width < 3)
pm_error("sharpness is undefined for an image less than 3 pixels "
"in all directions. This image is %d x %d",
inpam.width, inpam.height);
computeSharpness(&inpam, tuplenarray, &sharpness);
printf("Sharpness = %f\n", sharpness);
pnm_freepamarrayn(tuplenarray, &inpam);
pm_close(ifP);
return 0;
}
开发者ID:moseymosey,项目名称:netpbm,代码行数:30,代码来源:pamsharpness.c
示例20: at_bitmap_init
at_bitmap_type
at_bitmap_init(unsigned char * area,
unsigned short width,
unsigned short height,
unsigned int planes) {
at_bitmap_type bitmap;
if (area)
bitmap.bitmap = area;
else {
if (width * height == 0)
bitmap.bitmap = NULL;
else {
MALLOCARRAY(bitmap.bitmap, width * height * planes);
if (bitmap.bitmap == NULL)
pm_error("Unable to allocate %u x %u x %u bitmap array",
width, height, planes);
bzero(bitmap.bitmap,
width * height * planes * sizeof(unsigned char));
}
}
bitmap.width = width;
bitmap.height = height;
bitmap.np = planes;
return bitmap;
}
开发者ID:Eleanor66613,项目名称:CS131,代码行数:29,代码来源:bitmap.c
注:本文中的pm_error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论