int main( int argc, char const * const argv[] ) { if( 2 <= argc ) { image_t image ; if( imageFromFile( argv[1], image ) ) { unsigned x = 0 ; if( 3 <= argc ) x = strtoul( argv[2], 0, 0 ); unsigned y = 0 ; if( 4 <= argc ) y = strtoul( argv[3], 0, 0 ); #ifdef __DAVINCIFB__ #else getFB().render( x, y, image.width_, image.height_, (unsigned short *)image.pixData_ ); #endif } else perror( argv[1] ); } else fprintf( stderr, "Usage: imgFile fileName [x [y]]\n" ); return 0 ; }
uiState_t :: uiState_t( void ) : state_( 0 ) { if( !imageFromFile( "logo.jpg", welcomeImage_ ) ) fprintf( stderr, "Error reading welcome logo\n" ); if( !imageFromFile( "unlock.jpg", unlockImage_ ) ) fprintf( stderr, "Error reading unlocked image\n" ); if( !imageFromFile( "open.gif", openImage_ ) ) fprintf( stderr, "Error reading open image\n" ); images_[0] = &unlockImage_ ; images_[lock_e] = &welcomeImage_ ; images_[gateOpen_e] = &openImage_ ; images_[lock_e |gateOpen_e] = &openImage_ ; setState( lock_e, true ); }
vtkTexture * TextureManager::fromFile(const QString & fileName) { assert(s_instance); vtkSmartPointer<vtkTexture> tex = s_instance->fileToTexture.value(fileName); if (tex) return tex; vtkImageData * image = imageFromFile(fileName); if (!image) return nullptr; tex = vtkSmartPointer<vtkTexture>::New(); tex->SetInputData(image); s_instance->fileToTexture.insert(fileName, tex); return tex; }
void RefImage::loadImage() { // qDebug() << "Image Cached:" << imageCached; if (!isImageCached()) { if (isImageLocal() || isImageOnDisk()) { imageFromFile(); } else { downloadImage(); } } else emit newImage(imageItem()); setInView(true); }
int main( int argc, char const * const argv[] ) { if( 2 <= argc ) { image_t image ; if( imageFromFile( argv[1], image ) ) { unsigned w = image.width_ ; if( 3 <= argc ) w = strtoul( argv[2], 0, 0 ); unsigned h = image.height_ ; if( 4 <= argc ) h = strtoul( argv[3], 0, 0 ); if( ( w != image.width_ ) || ( h != image.height_ ) ){ unsigned const pixBytes = w*h*sizeof( short ); void *const pixMem = new unsigned short [w*h]; Scale16::scale( (unsigned short *)pixMem, w, h, (unsigned short *)image.pixData_, image.width_,image.height_, 0,0,image.width_,image.height_); image.unload(); delete [] ((unsigned short *)image.pixData_); image.pixData_ = pixMem ; image.width_ = w ; image.height_ = h ; } char *outData ; unsigned outLen ; imgMonoToPCL( image, outData, outLen ); fwrite( outData, outLen, 1, stdout ); } else perror( argv[1] ); } else fprintf( stderr, "Usage: %s fileName [w [h]]\n", argv[0] ); return 0 ; }
int main(int argc, char const * const argv[]) { if(2 <= argc) { image_t image; int mode; mode = DEFAULT_CURSOR_MODE; if( 3 <= argc ) mode = strtoul( argv[2], 0, 0 ); if(imageFromFile(argv[1], image)) perror(argv[1]); cursor_t cursor(mode); if(cursor.cursorFromFile(image)) perror(argv[1]); if(4 <= argc) { int fd = open(argv[3], O_WRONLY); if(-1 == fd) { printf("Unable to open cursor file to write image\n"); return -1; } if(cursor.getCursorSize() > write(fd, cursor.getCursorData(), cursor.getCursorSize())) { printf("Unable to write complete cursor image\n"); return -1; } close(fd); } } else fprintf(stderr, "Usage: cursorFile fileName [mode [convertedImgFile]]\n"); return 0; }
int main( int argc, char const * const argv[] ) { fbDevice_t &fb = getFB(); image_t img ; memset( &img, 0, sizeof( img ) ); if( 1 < argc ) { if( imageFromFile( argv[1], img ) ) printf( "%s: %u x %u pixels\n", argv[1], img.width_, img.height_ ); else perror( argv[1] ); } else { img.pixData_ = fb.getRow(0); img.width_ = fb.getWidth(); img.height_ = fb.getHeight(); img.alpha_ = 0 ; } if( img.pixData_ ) { dither_t dither( (unsigned short const *)img.pixData_, img.width_, img.height_ ); unsigned bpl = bitmap_t::bytesPerRow(img.width_); unsigned char * const bitmapBytes = new unsigned char[bpl*img.height_]; bitmap_t bmp( bitmapBytes, img.width_, img.height_ ); for( unsigned row = 0 ; row < img.height_ ; row++ ) { unsigned char mask = 0x80 ; unsigned char *outRow = bitmapBytes+row*bpl ; for( unsigned col = 0 ; col < img.width_ ; col++ ) { if( dither.isBlack(col,row) ) *outRow |= mask ; else *outRow &= ~mask ; mask >>= 1 ; if( 0 == mask ){ mask = 0x80 ; outRow++ ; } } // each column } // each row void const *outData ; unsigned outSize ; if( bitmapToPNG( bmp, outData, outSize ) ) { printf( "%u bytes of output\n", outSize ); char const *outFile = ( 2 < argc ) ? argv[2] : "/tmp/img.png" ; FILE *fOut = fopen( outFile, "wb" ); if( fOut ) { fwrite( outData, 1, outSize, fOut ); fclose( fOut ); printf( "%u bytes written to %s\n", outSize, outFile ); } else perror( outFile ); free((void *)outData); } else printf( "Error converting bitmap\n" ); }