Beispiel #1
0
static bool nspng_convert(struct content *c)
{
	nspng_content *png_c = (nspng_content *) c;
	char *title;

	assert(png_c->png != NULL);
	assert(png_c->info != NULL);

	/* clean up png structures */
	png_destroy_read_struct(&png_c->png, &png_c->info, 0);

	/* set title text */
	title = messages_get_buff("PNGTitle",
			nsurl_access_leaf(llcache_handle_get_url(c->llcache)),
			c->width, c->height);
	if (title != NULL) {
		content__set_title(c, title);
		free(title);
	}

	if (png_c->bitmap != NULL) {
		bitmap_set_opaque(png_c->bitmap, bitmap_test_opaque(png_c->bitmap));
		bitmap_modified(png_c->bitmap);
	}

	image_cache_add(c, png_c->bitmap, png_cache_convert);

	content_set_ready(c);
	content_set_done(c);
	content_set_status(c, "");

	return true;
}
Beispiel #2
0
/**
 * Convert a CONTENT_JPEG for display.
 */
static bool nsjpeg_convert(struct content *c)
{
	struct jpeg_decompress_struct cinfo;
	struct jpeg_error_mgr jerr;
	jmp_buf setjmp_buffer;
	struct jpeg_source_mgr source_mgr = { 0, 0,
		nsjpeg_init_source, nsjpeg_fill_input_buffer,
		nsjpeg_skip_input_data, jpeg_resync_to_restart,
		nsjpeg_term_source };
	union content_msg_data msg_data;
	const char *data;
	unsigned long size;
	char title[100];

	/* check image header is valid and get width/height */
	data = content__get_source_data(c, &size);

	cinfo.err = jpeg_std_error(&jerr);
	jerr.error_exit = nsjpeg_error_exit;
	jerr.output_message = nsjpeg_error_log;

	if (setjmp(setjmp_buffer)) {
		jpeg_destroy_decompress(&cinfo);

		msg_data.error = nsjpeg_error_buffer;
		content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
		return false;
	}

	jpeg_create_decompress(&cinfo);
	cinfo.client_data = &setjmp_buffer;
	source_mgr.next_input_byte = (unsigned char *) data;
	source_mgr.bytes_in_buffer = size;
	cinfo.src = &source_mgr;
	jpeg_read_header(&cinfo, TRUE);
	cinfo.out_color_space = JCS_RGB;
	cinfo.dct_method = JDCT_ISLOW;

	jpeg_calc_output_dimensions(&cinfo);

	c->width = cinfo.output_width;
	c->height = cinfo.output_height;
	c->size = c->width * c->height * 4;

	jpeg_destroy_decompress(&cinfo);

	image_cache_add(c, NULL, jpeg_cache_convert);

	snprintf(title, sizeof(title), messages_get("JPEGTitle"), 
		 c->width, c->height, size);
	content__set_title(c, title);

	content_set_ready(c);
	content_set_done(c);	
	content_set_status(c, ""); /* Done: update status bar */

	return true;
}
Beispiel #3
0
bool amiga_dt_picture_convert(struct content *c)
{
	LOG(("amiga_dt_picture_convert"));

	union content_msg_data msg_data;
	int width, height;
	char title[100];
	const uint8 *data;
	UBYTE *bm_buffer;
	ULONG size;
	Object *dto;
	struct BitMapHeader *bmh;
	unsigned int bm_flags = BITMAP_NEW;
	int bm_format = PBPAFMT_RGBA;

	/* This is only relevant for picture datatypes... */

	data = (uint8 *)content__get_source_data(c, &size);

	if(dto = NewDTObject(NULL,
					DTA_SourceType, DTST_MEMORY,
					DTA_SourceAddress, data,
					DTA_SourceSize, size,
					DTA_GroupID, GID_PICTURE,
					PDTA_DestMode, PMODE_V43,
					TAG_DONE))
	{
		if(GetDTAttrs(dto, PDTA_BitMapHeader, &bmh, TAG_DONE))
		{
			width = (int)bmh->bmh_Width;
			height = (int)bmh->bmh_Height;
		}
		else return false;

		DisposeDTObject(dto);
	}
	else return false;

	c->width = width;
	c->height = height;
	c->size = width * height * 4;

	image_cache_add(c, NULL, amiga_dt_picture_cache_convert);

/*
	snprintf(title, sizeof(title), "image (%lux%lu, %lu bytes)",
		width, height, size);
	content__set_title(c, title);
*/

	content_set_ready(c);
	content_set_done(c);

	content_set_status(c, "");
	return true;
}
Beispiel #4
0
bool amiga_dt_picture_convert(struct content *c)
{
	LOG(("amiga_dt_picture_convert"));

	union content_msg_data msg_data;
	int width, height;
	char *title;
	UBYTE *bm_buffer;
	Object *dto;
	struct BitMapHeader *bmh;
	unsigned int bm_flags = BITMAP_NEW;
	int bm_format = PBPAFMT_RGBA;
	char *filetype;

	if(dto = amiga_dt_picture_newdtobject((struct amiga_dt_picture_content *)c))
	{
		if(GetDTAttrs(dto, PDTA_BitMapHeader, &bmh, TAG_DONE))
		{
			width = (int)bmh->bmh_Width;
			height = (int)bmh->bmh_Height;
		}
		else return false;
	}
	else return false;

	c->width = width;
	c->height = height;
	c->size = width * height * 4;

	/* set title text */
	if(filetype = amiga_dt_picture_datatype(c)) {
		title = messages_get_buff("DataTypesTitle",
			nsurl_access_leaf(llcache_handle_get_url(c->llcache)),
			filetype, c->width, c->height);
		if (title != NULL) {
			content__set_title(c, title);
			free(title);
		}
		free(filetype);
	}
	
	image_cache_add(c, NULL, amiga_dt_picture_cache_convert);

	content_set_ready(c);
	content_set_done(c);
	content_set_status(c, "");
	return true;
}
Beispiel #5
0
bool amiga_dt_picture_convert(struct content *c)
{
	NSLOG(netsurf, INFO, "amiga_dt_picture_convert");

	int width, height;
	char *title;
	Object *dto;
	struct BitMapHeader *bmh;
	char *filetype;

	if((dto = amiga_dt_picture_newdtobject((struct amiga_dt_picture_content *)c))) {
		if(GetDTAttrs(dto, PDTA_BitMapHeader, &bmh, TAG_DONE)) {
			width = (int)bmh->bmh_Width;
			height = (int)bmh->bmh_Height;
		}
		else return false;
	}
	else return false;

	c->width = width;
	c->height = height;
	c->size = width * height * 4;

	/* set title text */
	if((filetype = amiga_dt_picture_datatype(c))) {
		title = messages_get_buff("DataTypesTitle",
			nsurl_access_leaf(llcache_handle_get_url(c->llcache)),
			filetype, c->width, c->height);
		if (title != NULL) {
			content__set_title(c, title);
			free(title);
		}
		free(filetype);
	}
	
	image_cache_add(c, NULL, amiga_dt_picture_cache_convert);

	content_set_ready(c);
	content_set_done(c);
	content_set_status(c, "");
	return true;
}