本文整理汇总了C++中ReadOK函数的典型用法代码示例。如果您正苦于以下问题:C++ ReadOK函数的具体用法?C++ ReadOK怎么用?C++ ReadOK使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReadOK函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDataBlock
static int GetDataBlock (MG_RWops *area, unsigned char *buf)
{
unsigned char count;
if (!ReadOK(area, &count, 1))
return 0;
ZeroDataBlock = (count == 0);
if ((count != 0) && (!ReadOK(area, buf, count)))
return 0;
return count;
}
示例2: ReadPalette
static bool ReadPalette( RageFile &f, int number, RageSurfaceColor buffer[MAXCOLORMAPSIZE] )
{
for( int i = 0; i < number; ++i )
{
if( !ReadOK(f, &buffer[i].r, sizeof(buffer[i].r)) )
return false;
if( !ReadOK(f, &buffer[i].g, sizeof(buffer[i].g)) )
return false;
if( !ReadOK(f, &buffer[i].b, sizeof(buffer[i].b)) )
return false;
buffer[i].a = 0xFF;
}
return true;
}
示例3: Init
bool LWZState::Init( RageFile &f )
{
unsigned char input_code_size;
/* code size: */
if( !ReadOK(f, &input_code_size, 1) )
{
// RWSetMsg("EOF / read error on image data");
return false;
}
set_code_size = input_code_size;
code_size = set_code_size + 1;
clear_code = 1 << set_code_size;
end_code = clear_code + 1;
max_code_size = 2 * clear_code;
max_code = clear_code + 2;
m_Code.Init();
fresh = true;
memset( table, 0, sizeof(table) );
for( int i = 0; i < clear_code; ++i )
table[1][i] = i;
sp = stack;
return true;
}
示例4: ReadColorMap
static gboolean
ReadColorMap (FILE *fd,
gint number,
CMap buffer,
gint *format)
{
guchar rgb[3];
gint flag;
gint i;
flag = TRUE;
for (i = 0; i < number; ++i)
{
if (! ReadOK (fd, rgb, sizeof (rgb)))
return FALSE;
buffer[CM_RED][i] = rgb[0];
buffer[CM_GREEN][i] = rgb[1];
buffer[CM_BLUE][i] = rgb[2];
flag &= (rgb[0] == rgb[1] && rgb[1] == rgb[2]);
}
*format = (flag) ? GRAYSCALE : COLOR;
return TRUE;
}
示例5: TIFFReadRawStrip1
static tsize_t
TIFFReadRawStrip1(TIFF* tif,
tstrip_t strip, tdata_t buf, tsize_t size, const char* module)
{
TIFFDirectory *td = &tif->tif_dir;
if (!isMapped(tif)) {
if (!SeekOK(tif, td->td_stripoffset[strip])) {
TIFFError(module,
"%s: Seek error at scanline %lu, strip %lu",
tif->tif_name,
(u_long) tif->tif_row, (u_long) strip);
return (-1);
}
if (!ReadOK(tif, buf, size)) {
TIFFError(module, "%s: Read error at scanline %lu",
tif->tif_name, (u_long) tif->tif_row);
return (-1);
}
} else {
if (td->td_stripoffset[strip] + size > tif->tif_size) {
TIFFError(module,
"%s: Seek error at scanline %lu, strip %lu",
tif->tif_name,
(u_long) tif->tif_row, (u_long) strip);
return (-1);
}
memcpy(buf, tif->tif_base + td->td_stripoffset[strip], size);
}
return (size);
}
示例6: ReadImageDesc
static int ReadImageDesc (MG_RWops *area, IMAGEDESC* ImageDesc, GIFSCREEN* GifScreen)
{
unsigned char buf[16];
if (!ReadOK (area, buf, 9)) {
_MG_PRINTF ("EX_CTRL>GIF89a: bad image size\n");
return -1;
}
ImageDesc->Top = LM_to_uint (buf[0], buf[1]);
ImageDesc->Left = LM_to_uint (buf[2], buf[3]);
ImageDesc->Width = LM_to_uint (buf[4], buf[5]);
ImageDesc->Height = LM_to_uint (buf[6], buf[7]);
ImageDesc->haveColorMap = BitSet (buf[8], LOCALCOLORMAP);
ImageDesc->bitPixel = 1 << ((buf[8] & 0x07) + 1);
ImageDesc->interlace = BitSet(buf[8], INTERLACE);
if (ImageDesc->haveColorMap) {
_MG_PRINTF ("EX_CTRL>GIF89a: have local colormap\n");
if (ReadColorMap (area, ImageDesc->bitPixel, ImageDesc->ColorMap) < 0) {
_MG_PRINTF ("EX_CTRL>GIF89a: bad local colormap\n");
return -1;
}
} else {
memcpy (ImageDesc->ColorMap, GifScreen->ColorMap, MAXCOLORMAPSIZE*sizeof (RGB));
}
return 0;
}
示例7: ReadColorMap
static int
ReadColorMap(SDL_RWops *src, int number,
unsigned char buffer[3][MAXCOLORMAPSIZE], int *gray)
{
int i;
unsigned char rgb[3];
int flag;
flag = TRUE;
for (i = 0; i < number; ++i) {
if (!ReadOK(src, rgb, sizeof(rgb))) {
IMG_SetError("bad colormap");
return 1;
}
buffer[CM_RED][i] = rgb[0];
buffer[CM_GREEN][i] = rgb[1];
buffer[CM_BLUE][i] = rgb[2];
flag &= (rgb[0] == rgb[1] && rgb[1] == rgb[2]);
}
#if 0
if (flag)
*gray = (number == 2) ? PBM_TYPE : PGM_TYPE;
else
*gray = PPM_TYPE;
#else
*gray = 0;
#endif
return FALSE;
}
示例8: get_word_rgb_row
get_word_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
/* This version is for reading raw-word-format PPM files with any maxval */
{
ppm_source_ptr source = (ppm_source_ptr) sinfo;
register JSAMPROW ptr;
register U_CHAR * bufferptr;
register JSAMPLE *rescale = source->rescale;
JDIMENSION col;
if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
ERREXIT(cinfo, JERR_INPUT_EOF);
ptr = source->pub.buffer[0];
bufferptr = source->iobuffer;
for (col = cinfo->image_width; col > 0; col--) {
register int temp;
temp = UCH(*bufferptr++) << 8;
temp |= UCH(*bufferptr++);
*ptr++ = rescale[temp];
temp = UCH(*bufferptr++) << 8;
temp |= UCH(*bufferptr++);
*ptr++ = rescale[temp];
temp = UCH(*bufferptr++) << 8;
temp |= UCH(*bufferptr++);
*ptr++ = rescale[temp];
}
return 1;
}
示例9: copyFaxFile
int
copyFaxFile(TIFF* tifin, TIFF* tifout)
{
uint32 row;
uint16 badrun;
int ok;
tifin->tif_rawdatasize = TIFFGetFileSize(tifin);
tifin->tif_rawdata = _TIFFmalloc(tifin->tif_rawdatasize);
if (!ReadOK(tifin, tifin->tif_rawdata, tifin->tif_rawdatasize)) {
TIFFError(tifin->tif_name, "%s: Read error at scanline 0");
return (0);
}
tifin->tif_rawcp = tifin->tif_rawdata;
tifin->tif_rawcc = tifin->tif_rawdatasize;
(*tifin->tif_setupdecode)(tifin);
(*tifin->tif_predecode)(tifin, (tsample_t) 0);
tifin->tif_row = 0;
badfaxlines = 0;
badfaxrun = 0;
_TIFFmemset(refbuf, 0, sizeof (refbuf));
row = 0;
badrun = 0; /* current run of bad lines */
while (tifin->tif_rawcc > 0) {
ok = (*tifin->tif_decoderow)(tifin, rowbuf, sizeof (rowbuf), 0);
if (!ok) {
badfaxlines++;
badrun++;
/* regenerate line from previous good line */
_TIFFmemcpy(rowbuf, refbuf, sizeof (rowbuf));
} else {
if (badrun > badfaxrun)
badfaxrun = badrun;
badrun = 0;
_TIFFmemcpy(refbuf, rowbuf, sizeof (rowbuf));
}
tifin->tif_row++;
if (TIFFWriteScanline(tifout, rowbuf, row, 0) < 0) {
fprintf(stderr, "%s: Write error at row %ld.\n",
tifout->tif_name, (long) row);
break;
}
row++;
if (stretch) {
if (TIFFWriteScanline(tifout, rowbuf, row, 0) < 0) {
fprintf(stderr, "%s: Write error at row %ld.\n",
tifout->tif_name, (long) row);
break;
}
row++;
}
}
if (badrun > badfaxrun)
badfaxrun = badrun;
_TIFFfree(tifin->tif_rawdata);
return (row);
}
示例10: ReadGIFGlobal
static int ReadGIFGlobal (MG_RWops *area, GIFSCREEN* GifScreen)
{
unsigned char buf[9];
unsigned char version[4];
if (!ReadOK (area, buf, 6))
return -1; /* not gif image*/
if (strncmp((char *) buf, "GIF", 3) != 0)
return -1;
strncpy ((char*)version, (char *) buf + 3, 3);
version [3] = '\0';
if (strcmp ((const char*)version, "87a") != 0 && strcmp ((const char*)version, "89a") != 0) {
_MG_PRINTF ("EX_CTRL>GIF89a: GIF version number not 87a or 89a.\n");
return -1; /* image loading error*/
}
GifScreen->Background = -1;
GifScreen->transparent = -1;
GifScreen->delayTime = -1;
GifScreen->inputFlag = -1;
GifScreen->disposal = 0;
if (!ReadOK (area, buf, 7)) {
_MG_PRINTF ("EX_CTRL>GIF89a: bad screen descriptor\n");
return -1; /* image loading error*/
}
GifScreen->Width = LM_to_uint (buf[0], buf[1]);
GifScreen->Height = LM_to_uint (buf[2], buf[3]);
GifScreen->BitPixel = 2 << (buf[4] & 0x07);
GifScreen->ColorResolution = (((buf[4] & 0x70) >> 3) + 1);
GifScreen->Background = buf[5];
GifScreen->AspectRatio = buf[6];
if (BitSet(buf[4], LOCALCOLORMAP)) { /* Global Colormap */
_MG_PRINTF ("EX_CTRL>GIF89a: have global colormap: %d\n",
GifScreen->Background);
if (ReadColorMap (area, GifScreen->BitPixel, GifScreen->ColorMap)) {
_MG_PRINTF ("EX_CTRL>GIF89a: bad global colormap\n");
return -1; /* image loading error*/
}
}
return 0;
}
示例11: GetDataBlock
static int GetDataBlock( RageFile &f, unsigned char *buf )
{
unsigned char count;
if( !ReadOK(f, &count, 1) )
{
/* pm_message("error in getting DataBlock size" ); */
return -1;
}
if( count != 0 && !ReadOK(f, buf, count) )
{
/* pm_message("error in reading DataBlock" ); */
return -1;
}
return count;
}
示例12: GetDataBlock
static int
GetDataBlock(SDL_RWops *src, unsigned char *buf)
{
unsigned char count;
if (!ReadOK(src, &count, 1)) {
dbgout("error in getting DataBlock size\n");
return -1;
}
ZeroDataBlock = count == 0;
if ((count != 0) && (!ReadOK(src, buf, count))) {
dbgout("error in reading DataBlock\n");
return -1;
}
return count;
}
示例13: GetDataBlock
static int GetDataBlock(FILE *fd, unsigned char *buf){
unsigned char count;
if (! ReadOK(fd,&count,1)) {
fprintf(stderr,"error in getting DataBlock size\n" );
return -1;
}
ZeroDataBlock = count == 0;
if ((count != 0) && (! ReadOK(fd, buf, count))) {
fprintf(stderr,"error in reading DataBlock\n" );
return -1;
}
return count;
}
示例14: get_raw_row
get_raw_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
/* This version is for reading raw-byte-format files with maxval = MAXJSAMPLE.
* In this case we just read right into the JSAMPLE buffer!
* Note that same code works for PPM and PGM files.
*/
{
ppm_source_ptr source = (ppm_source_ptr) sinfo;
if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
ERREXIT(cinfo, JERR_INPUT_EOF);
return 1;
}
示例15:
Node *Next(List *pList, Node *pNode)
{
if (!ReadOK(&pList->lock))
{
FatalError("Next - Not allowed to read!");
return NULL;
}
if (pNode == NULL)
return pList->pHead;
else
return pNode->pNext;
}