示例#1
0
jpg_reader_t::jpg_reader_t( const boost::filesystem::path& p) : reader_t( p)
{
    int width, height;

    if( !get_jpeg_size( filesystem::file_cstring( p), width, height ))
		throw unknown_image_format();

    info_[ adobe::name_t( "format")] = adobe::any_regular_t( Imath::Box2i( Imath::V2i( 0, 0), Imath::V2i( width-1, height-1)));
}
示例#2
0
int main(int argc, char **argv)
{
    char *infilename, *outfilename;
    FILE *rFile,*wFile;
    int lSize,i,ind = 0,count = 0;
    int flag = 1;
    int range;
    int id;
    int ret;
    unsigned char *buffer = NULL;
    size_t result;


    if(argc == 2)
    {
        infilename = argv[1];
    }
    else
    {
        fprintf(stderr, "input format error\n");
        exit(0);
    }


    printf("Devcie ID = %d\n", id);
    printf("Input file name = %s\n", infilename);
    printf("Output file name = %s\n", outfilename);

    char get_char;
    int p = 0;
    int SendDevice;
    int SendSize;
    int sum = 0;

    //Read Image from file(camera)
    lSize = ImageFromFile(infilename, &buffer);
    unsigned short width,height;
    bool jpegfile;
    jpegfile =get_jpeg_size(buffer, lSize, &width, &height);
    if(jpegfile)
        printf("width = %d\nheight = %d\n",width,height);
    else
        printf("Not jpeg file\n");
    free(buffer);


    return 0;
}
示例#3
0
/*-----------------------------------------------------------
  image processing procedures
  
  image2jpeg: encodes raw image to jpeg
  add_text: adds a caption to the image
  swap_rgb24: RGB->RBG
  fliph: flips the image horizontally
  flipv: flips vertically
  -----------------------------------------------------------*/
int image2jpeg(struct image *img, char **jpeg_data, int quality)
{
	struct jpeg_compress_struct cinfo;
	struct jpeg_error_mgr jerr;
	int i, size;
	int w, h;
	unsigned char *line;
	
	w = img->width;
	h = img->height;

	cinfo.err = jpeg_std_error(&jerr);
	jpeg_create_compress(&cinfo);
	jpeg_buff_dest(&cinfo);
	cinfo.image_width = w;
	cinfo.image_height = h;
	cinfo.input_components = 3;
	cinfo.in_color_space = JCS_RGB;
	jpeg_set_defaults(&cinfo);
	jpeg_set_quality(&cinfo, quality, TRUE);
	jpeg_start_compress(&cinfo, TRUE);
	for (i = 0, line = img->buf; i < h; i++, line += w*3)
		jpeg_write_scanlines(&cinfo, &line, 1);
	jpeg_finish_compress(&cinfo);
	
	size = get_jpeg_size(&cinfo);
	
	/* this memory must be freed elsewhere */
	(*jpeg_data) = (char *)malloc(size);
	if(!(*jpeg_data))
	{
		jpeg_destroy_compress(&cinfo);
		jpeg_buff_free(&cinfo);
		return -1;
	}
	memcpy(*jpeg_data, ((my_dest_ptr)cinfo.dest)->buffer, size);

	jpeg_destroy_compress(&cinfo);
	jpeg_buff_free(&cinfo);
	
	return size;
}