/* * Executes underlying scan method to fetch the next matching tuple. */ TupleTableSlot * BitmapTableScanFetchNext(ScanState *node) { BitmapTableScanState *scanState = (BitmapTableScanState *) node; TupleTableSlot *slot = BitmapTableScanPlanQualTuple(scanState); while (TupIsNull(slot)) { /* If we haven't already obtained the required bitmap, do so */ readBitmap(scanState); /* If we have exhausted the current bitmap page, fetch the next one */ if (!scanState->needNewBitmapPage || fetchNextBitmapPage(scanState)) { slot = ExecScan(&scanState->ss, (ExecScanAccessMtd) getBitmapTableScanMethod(scanState->ss.tableType)->accessMethod); } else { /* * Needed a new bitmap page, but couldn't fetch one. Therefore, * try the next partition. */ break; } } return slot; }
HBITMAP ReadBitmapFile( HWND hwnd, char *file_name, bitmap_info *info ) { FILE *fp; HBITMAP bitmap_handle; BITMAPFILEHEADER file_header; bool core; DWORD size; bitmap_handle = (HBITMAP)0; fp = fopen( file_name, "rb" ); if( fp == NULL ) { return( bitmap_handle ); } fread( &file_header, sizeof( BITMAPFILEHEADER ), 1, fp ); if( file_header.bfType != BITMAP_TYPE ) { fclose( fp ); return( bitmap_handle ); } fread( &size, sizeof( size ), 1, fp ); core = (size == sizeof( BITMAPCOREHEADER )); if( !core ) { bitmap_handle = readBitmap( hwnd, fp, file_header.bfOffBits, core, info ); } if( info != NULL ) { info->is_core = core; } fclose( fp ); return( bitmap_handle ); } /* ReadBitmapFile */
int myMount(MyFileSystem *myFileSystem, char *backupFileName){ if ((myFileSystem->fdVirtualDisk = open(backupFileName, O_RDWR))==-1){ perror(backupFileName); return 1; } if (readBitmap(myFileSystem)!=0){ fprintf(stderr,"Can't read bitmap\n"); return 2; } if (readSuperblock(myFileSystem)!=0){ fprintf(stderr,"Can't read superblock\n"); return 3; } if (readInodes(myFileSystem)!=0){ fprintf(stderr,"Can't read inodes\n"); return 4; } if (readDirectory(myFileSystem)!=0){ fprintf(stderr,"Can't read directory\n"); return 5; } printf("SF: %s, %d B (%d B/block), %d blocks\n", backupFileName, myFileSystem->superBlock.diskSizeInBlocks*BLOCK_SIZE_BYTES, BLOCK_SIZE_BYTES, myFileSystem->superBlock.diskSizeInBlocks); printf("1 block for SUPERBLOCK (%u B)\n", (unsigned int)sizeof(SuperBlockStruct)); printf("1 block for BITMAP, covering %u blocks, %u B\n", (unsigned int)NUM_BITS, (unsigned int)(NUM_BITS * BLOCK_SIZE_BYTES)); printf("1 block for DIRECTORY (%u B)\n", (unsigned int)sizeof(DirectoryStruct)); printf("%d blocks for inodes (%u B/inode, %u inodes)\n", MAX_BLOCKS_WITH_NODES, (unsigned int)sizeof(NodeStruct), (unsigned int)MAX_NODES); printf("%d blocks for data (%d B)\n", myFileSystem->superBlock.numOfFreeBlocks, BLOCK_SIZE_BYTES * myFileSystem->superBlock.numOfFreeBlocks); printf("Volume mounted successfully!\n"); return 0; }
ERR_EXISTS readFile(const char *infile, PixImg *img, PixErr *err) { Bitmap b = {0}; if(!readBitmap(infile, &b, err)) return ERR; if(!bitmapToImage(&b, img, err)) return ERR; return NO_ERR; }
ObjectNode *op_LoadBmp (ExecuteHandler execute, Context *context, Node *node){ void *res = NULL; ObjectNode *objpath = execute(context, &node->childs[0]); char *path = listToString(objpath); BITMAP bmp; if(readBitmap(&bmp, path)) return newObjectNode(NTYPE_NONE, NULL); res = (void *) mkList(&bmp); freeBitmap(&bmp); return res; }
bool CursorHandler::read(QImage *image) { readHeaderIfNecessary(); if (state != BeforeImage) return false; quint32 size; quint32 width; quint32 height; quint16 numPlanes; quint16 bitsPerPixel; quint32 compression; QDataStream in(device()); in.setByteOrder(QDataStream::LittleEndian); in >> size; if (size != 40) { enterErrorState(); return false; } in >> width >> height >> numPlanes >> bitsPerPixel >> compression; height /= 2; if (numPlanes != 1 || bitsPerPixel != 1 || compression != 0) { enterErrorState(); return false; } in.skipRawData((size - 20) + 8); QBitArray xorBitmap = readBitmap(width, height, in); QBitArray andBitmap = readBitmap(width, height, in); if (in.status() != QDataStream::Ok) { enterErrorState(); return false; } *image = QImage(width, height, QImage::Format_ARGB32); for (int i = 0; i < int(height); ++i) { for (int j = 0; j < int(width); ++j) { QRgb color; int bit = (i * width) + j; if (andBitmap.testBit(bit)) { if (xorBitmap.testBit(bit)) { color = 0x7F7F7F7F; } else { color = 0x00FFFFFF; } } else { if (xorBitmap.testBit(bit)) { color = 0xFFFFFFFF; } else { color = 0xFF000000; } } image->setPixel(j, i, color); } } ++currentImageNo; if (currentImageNo == numImages) state = AfterLastImage; return true; }
bool GifDecoder::readContents(DataBlock* dataBlock) { // read GIF file content blocks uint8_t code; while (true) { if (!dataBlock->read(&code, 1)) { return false; } switch (code) { case 0x2C: // image separator if (!readBitmap(dataBlock)) { return false; } break; case 0x21: // extension if (!dataBlock->read(&code, 1)) { return false; } switch (code) { case 0xf9: // graphics control extension if (!readGraphicControlExt(dataBlock)) { return false; } break; case 0xff: // application extension uint8_t blockSize; readBlock(dataBlock, &blockSize); if (0 == memcmp("NETSCAPE2.0", block, 11)) { if (!readNetscapeExt(dataBlock)) { return false; } } else { // don't care if (!skip(dataBlock)) { return false; } } break; case 0xfe:// comment extension if (!skip(dataBlock)) { return false; } break; case 0x01:// plain text extension if (!skip(dataBlock)) { return false; } break; default: // uninteresting extension if (!skip(dataBlock)) { return false; } } break; case 0x3b: // terminator return true; case 0x00: // bad byte, but keep going and see what happens break; default: return false; } } }
PixmapArray::PixmapArray( XInfo& xinfo ) { readBitmap( xinfo, pixmaps, "res/button_quit.xbm", PixmapArray::BUTTON_QUIT ); readBitmap( xinfo, pixmaps, "res/button_quit_pressed.xbm", PixmapArray::BUTTON_QUIT_PRESSED ); readBitmap( xinfo, pixmaps, "res/button_start.xbm", PixmapArray::BUTTON_START ); readBitmap( xinfo, pixmaps, "res/button_start_pressed.xbm", PixmapArray::BUTTON_START_PRESSED ); readBitmap( xinfo, pixmaps, "res/button_resume.xbm", PixmapArray::BUTTON_RESUME ); readBitmap( xinfo, pixmaps, "res/button_resume_pressed.xbm", PixmapArray::BUTTON_RESUME_PRESSED ); readBitmap( xinfo, pixmaps, "res/button_retry.xbm", PixmapArray::BUTTON_RETRY ); readBitmap( xinfo, pixmaps, "res/button_retry_pressed.xbm", PixmapArray::BUTTON_RETRY_PRESSED ); readBitmap( xinfo, pixmaps, "res/stalin.xbm", PixmapArray::STALIN ); readBitmap( xinfo, pixmaps, "res/title.xbm", PixmapArray::TITLE ); readBitmap( xinfo, pixmaps, "res/failure.xbm", PixmapArray::FAIL ); }