int main(int argc, char **argv) { try { const char* filename = argc == 2 ? argv[1] : FNAME; JPEG jpeg((char*) filename); // create jpeg object for a file jpeg.GetDCTs(); // get DCT coefficients from file std::cout << "Read is OK\n"; // if (!jpeg.cmpWith((char*) LOG)) { // compare DCTs with existing // std::cout << "Not equal\n"; // return 1; // } // jpeg.PrintData(); // std::cout << "All is OK\n"; KZanalizer kz(jpeg.begin(), jpeg.end(), _CB); // create Analizer object if(kz.Analize()) printf("this is stego: %.3f\%\n", kz.GetProbability()); else printf("this is not stego: %.3f\%\n", kz.GetProbability()); } catch (my_exception exc) { std::cerr << exc.what() << std::endl; if ( int const * mi=boost::get_error_info<int_info>(exc) ) std::cerr << *mi << std::endl; if ( std::string const * ms=boost::get_error_info<str_info>(exc) ) std::cerr << *ms << std::endl; return errno; } catch (...){ std::cerr << "Unknown exception" << std::endl; } // histtest(); return 0; }
/**************************************************************************** * @func : JPEG save Thread main funtion * @arg1 : void * @return : void ***************************************************************************/ void *jpegsaveThread(void) { unsigned char* rgb; char outfile[100] = {0}; FILE *fp; SERVER_CONFIG *serverConfig = GetServerConfig(); while(!KillJpegsaveThread) { while(serverConfig->jpeg.framebuff == NULL) { usleep(100); } get_image_filename(outfile,serverConfig->image.type); fp = fopen(outfile, "w"); switch(serverConfig->image.type) { case 0: apply_algo((char *)serverConfig->jpeg.framebuff,serverConfig->algo_type); rgb = yuyv2rgb(serverConfig->jpeg.framebuff, serverConfig->capture.width, serverConfig->capture.height); jpeg(fp, rgb, serverConfig->capture.width, serverConfig->capture.height, serverConfig->jpeg.quality); free(rgb); break; case 1: fwrite(serverConfig->jpeg.framebuff,serverConfig->capture.framesize,1,fp); break; } free(serverConfig->jpeg.framebuff); serverConfig->jpeg.framebuff = NULL; fclose(fp); } return 0; }
/** \fn DIA_animated \brief Dialog to set params for the animated filter */ uint8_t DIA_animated(ANIMATED_PARAM *param,uint32_t w, uint32_t h,uint32_t n) { uint8_t r=0; #define PX(x) &(param->x) diaElemFile jpeg(0,(char **)PX(backgroundImg),QT_TR_NOOP("_Background Image:"), NULL, QT_TR_NOOP("Select background image")); diaElemToggle isNtsc(PX(isNTSC),QT_TR_NOOP("_NTSC (default is PAL):")); diaElemUInteger vignetteW(PX(vignetteW),QT_TR_NOOP("Vignette _Width:"),16,w/3); diaElemUInteger vignetteH(PX(vignetteH),QT_TR_NOOP("Vignette _Height:"),16,h/2); diaElemUInteger *timecode[MAX_VIGNETTE]; diaElemFrame timecodes(QT_TR_NOOP("Vignette frame number")); for(int i=0;i<MAX_VIGNETTE;i++) { timecode[i]=new diaElemUInteger(&(param->timecode[i]),QT_TR_NOOP("Timecode:"),0,n); timecodes.swallow(timecode[i]); } diaElem *elems[5]={&jpeg,&isNtsc,&vignetteW,&vignetteH,&timecodes}; if( diaFactoryRun(QT_TR_NOOP("Animated Menu"),5,elems)) { r=1; } for(int i=0;i<MAX_VIGNETTE;i++) { delete timecode[i]; } return r; }
int ISSImages::loadFilenames(const std::string directory, bool recursive) { DIR *dir; class dirent *ent; class stat st; dir = opendir(directory.c_str()); while ( (ent = readdir(dir)) != NULL ) { const std::string filename = ent->d_name; const std::string full_filename = directory + '/' + filename; // Skip "." and ".." if ( filename[0] == '.' ) continue; // Skip files that error out. If we care, we can // check errno and see why we failed, but for now, // simply skip 'em if ( stat(full_filename.c_str(), &st) == -1 ) continue; // If we're a directory, act accordingly if ( (st.st_mode & S_IFDIR) != 0 ) { // Skip directory symlinks to take the easy way out // of a potential infinite recursion loop. TODO: fancy // this up to look for a subdir of our current dir or // something more sophisticated than simply skipping if ( (st.st_mode & S_IFLNK ) != 0 ) continue; // Recurse if set if ( recursive ) loadFilenames( full_filename, recursive ); // Otherwise, skip the directory else continue; } // We're just a file else { std::string jpg(".jpg"); std::string jpeg(".jpeg"); //Check that it's a .jpg or .jpeg if ( full_filename.find(jpg, 0) != -1 || full_filename.find(jpeg, 0) != -1 ) filenames.push_back(full_filename); else std::cout << "Skipping non-JPG file " << full_filename << std::endl; } } closedir(dir); return 0; }
int main(int argc, char *argv[]) { int width, height; char *end; FILE *io_in, *io_out; io_in = stdin; io_out = stdout; if (argc < 3) { fprintf(stderr, "Usage: %s WIDTH HEIGHT [file] [file]\n", argv[0]); return 1; } if (argc > 3) { io_in = fopen(argv[3], "r"); if (!io_in) { fprintf(stderr, "Unable to open source file.\n"); return 1; } } if (argc > 4) { io_out = fopen(argv[4], "w"); if (!io_out) { fprintf(stderr, "Unable to open destination file.\n"); return 1; } } width = strtoul(argv[1], &end, 10); if (*end) { fprintf(stderr, "Error: Invalid width.\n"); return 1; } height = strtoul(argv[2], &end, 10); if (*end) { fprintf(stderr, "Error: Invalid height.\n"); return 1; } if (looks_like_png(io_in)) { png(io_in, io_out, width, height); } else { jpeg(io_in, io_out, width, height); } fclose(io_in); fclose(io_out); return 0; }
AReader::Error ReaderJpeg::read( imageCache &cache, const uint8_t* data, unsigned length, QString format ) const{ if( !can_read( data, length, format ) ) return ERROR_TYPE_UNKNOWN; try{ cache.set_info( 1 ); JpegDecompress jpeg( data, length ); jpeg.cinfo.client_data = &cache; //Save application data, we are interested in ICC profiles and EXIF metadata jpeg.saveMarker( ICC_META_TEST ); jpeg.saveMarker( EXIF_META_TEST ); /* READ EVERYTHING! jpeg_save_markers( &jpeg.cinfo, JPEG_COM, 0xFFFF ); for( unsigned i=0; i<16; i++ ) jpeg_save_markers( &jpeg.cinfo, JPEG_APP0+i, 0xFFFF ); //*/ //Read header and set-up image jpeg.readHeader(); jpeg_start_decompress( &jpeg.cinfo ); bool is_gray; switch( jpeg.cinfo.out_color_components ){ case 1: is_gray = true; break; case 3: is_gray = false; break; default: return ERROR_UNSUPPORTED; } QImage frame( jpeg.cinfo.output_width, jpeg.cinfo.output_height, QImage::Format_RGB32 ); //Read image auto buffer = std::make_unique<JSAMPLE[]>( jpeg.bytesPerLine() ); JSAMPLE* arr[1] = { buffer.get() }; while( jpeg.cinfo.output_scanline < jpeg.cinfo.output_height ){ auto out = (QRgb*)frame.scanLine( jpeg.cinfo.output_scanline ); jpeg_read_scanlines( &jpeg.cinfo, arr, 1 ); if( is_gray ) for( unsigned ix=0; ix<jpeg.cinfo.output_width; ix++ ) out[ix] = qRgb( buffer[ix], buffer[ix], buffer[ix] ); else for( unsigned ix=0; ix<jpeg.cinfo.output_width; ix++ ) out[ix] = qRgb( buffer[ix*3+0], buffer[ix*3+1], buffer[ix*3+2] ); } //Check all markers for( auto marker = jpeg.cinfo.marker_list; marker; marker = marker->next ){ //Check for and read ICC profile if( ICC_META_TEST.validate( marker ) ){ cache.set_profile( ColorProfile::fromMem( marker->data + ICC_META_TEST.length , marker->data_length - ICC_META_TEST.length ) ); } if( EXIF_META_TEST.validate( marker ) ){ meta exif( marker->data + EXIF_META_TEST.length , marker->data_length - EXIF_META_TEST.length ); cache.set_orientation( exif.get_orientation() ); //Read thumbnail cache.thumbnail = exif.get_thumbnail(); //TODO: We actually want to read this BEFORE the full image ;) //TODO: Actually do something with this info. Perhaps check for a profile as well! } /* Save data to file for debugging QFile f( "Jpeg marker " + QString::number(marker->marker-JPEG_APP0) + ".bin" ); f.open( QIODevice::WriteOnly ); f.write( (char*)marker->data, marker->data_length ); //*/ } jpeg_finish_decompress( &jpeg.cinfo ); cache.add_frame( frame, 0 ); //Cleanup and return cache.set_fully_loaded(); return ERROR_NONE; } catch( int err_code ){ switch( err_code ){ case JERR_NO_SOI: return ERROR_TYPE_UNKNOWN; default: return ERROR_FILE_BROKEN; }; } }