Exemplo n.º 1
0
static bool nsico_redraw(struct content *c, struct content_redraw_data *data,
		const struct rect *clip, const struct redraw_context *ctx)
{
	nsico_content *ico = (nsico_content *)c;
	struct bmp_image *bmp;

	/* select most appropriate sized icon for size */
	bmp = ico_find(ico->ico, data->width, data->height);
	if (bmp == NULL) {
		/* return error */
		LOG("Failed to select icon");
		return false;
	}

	/* ensure its decided */
	if (bmp->decoded == false) {
		if (bmp_decode(bmp) != BMP_OK) {
			return false;
		} else {
			LOG("Decoding bitmap");
			guit->bitmap->modified(bmp->bitmap);
		}

	}

	return image_bitmap_plot(bmp->bitmap, data, clip, ctx);
}
Exemplo n.º 2
0
static bool nsico_convert(struct content *c)
{
	nsico_content *ico = (nsico_content *) c;
	struct bmp_image *bmp;
	bmp_result res;
	union content_msg_data msg_data;
	const char *data;
	unsigned long size;
	char *title;

	/* set the ico data */
	data = content__get_source_data(c, &size);

	/* analyse the ico */
	res = ico_analyse(ico->ico, size, (unsigned char *) data);

	switch (res) {
	case BMP_OK:
		break;
	case BMP_INSUFFICIENT_MEMORY:
		msg_data.error = messages_get("NoMemory");
		content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
		return false;
	case BMP_INSUFFICIENT_DATA:
	case BMP_DATA_ERROR:
		msg_data.error = messages_get("BadICO");
		content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
		return false;
	}

	/* Store our content width, height and calculate size */
	c->width = ico->ico->width;
	c->height = ico->ico->height;
	c->size += (ico->ico->width * ico->ico->height * 4) + 16 + 44;

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

	/* select largest icon to ensure one can be selected */
	bmp = ico_find(ico->ico, 255, 255);
	if (bmp == NULL) {
		/* return error */
		LOG("Failed to select icon");
		return false;
	}

	content_set_ready(c);
	content_set_done(c);

	/* Done: update status bar */
	content_set_status(c, "");
	return true;
}
Exemplo n.º 3
0
bool nsico_redraw(struct content *c, int x, int y,
		int width, int height,
		int clip_x0, int clip_y0, int clip_x1, int clip_y1,
		float scale, colour background_colour)
{
	struct bmp_image *bmp = ico_find(c->data.ico.ico, width, height);
	if (!bmp->decoded)
	  	if (bmp_decode(bmp) != BMP_OK)
			return false;
	c->bitmap = bmp->bitmap;
	return plot.bitmap(x, y, width, height, c->bitmap,
			background_colour, BITMAPF_NONE);
}
Exemplo n.º 4
0
bool nsico_convert(struct content *c)
{
	struct bmp_image *bmp;
	bmp_result res;
	ico_collection *ico;
	union content_msg_data msg_data;
	const char *data;
	unsigned long size;
	char title[100];

	/* set the ico data */
	ico = c->data.ico.ico;

	data = content__get_source_data(c, &size);

	/* analyse the ico */
	res = ico_analyse(ico, size, (unsigned char *) data);

	switch (res) {
	case BMP_OK:
		break;
	case BMP_INSUFFICIENT_MEMORY:
		msg_data.error = messages_get("NoMemory");
		content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
		return false;
	case BMP_INSUFFICIENT_DATA:
	case BMP_DATA_ERROR:
		msg_data.error = messages_get("BadICO");
		content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
		return false;
	}

	/* Store our content width and description */
	c->width = ico->width;
	c->height = ico->height;
	snprintf(title, sizeof(title), messages_get("ICOTitle"), 
			c->width, c->height, size);
	content__set_title(c, title);
	c->size += (ico->width * ico->height * 4) + 16 + 44;

	/* exit as a success */
	bmp = ico_find(c->data.ico.ico, 255, 255);
	assert(bmp);
	c->bitmap = bmp->bitmap;
	bitmap_modified(c->bitmap);
	c->status = CONTENT_STATUS_DONE;

	/* Done: update status bar */
	content_set_status(c, "");
	return true;
}
Exemplo n.º 5
0
bool nsico_set_bitmap_from_size(hlcache_handle *h, int width, int height)
{
	struct content *c = hlcache_handle_get_content(h);
	struct bmp_image *bmp;

	assert(c != NULL);

	bmp = ico_find(c->data.ico.ico, width, height);
	if (bmp == NULL)
		return false;

	if ((bmp->decoded == false) && (bmp_decode(bmp) != BMP_OK))
		return false;

	c->bitmap = bmp->bitmap;

	return true;
}
Exemplo n.º 6
0
bool nsico_redraw_tiled(struct content *c, int x, int y,
		int width, int height,
		int clip_x0, int clip_y0, int clip_x1, int clip_y1,
		float scale, colour background_colour,
		bool repeat_x, bool repeat_y)
{
	struct bmp_image *bmp = ico_find(c->data.ico.ico, width, height);
	bitmap_flags_t flags = BITMAPF_NONE;

	if (!bmp->decoded)
		if (bmp_decode(bmp) != BMP_OK)
			return false;

	c->bitmap = bmp->bitmap;

	if (repeat_x)
		flags |= BITMAPF_REPEAT_X;
	if (repeat_y)
		flags |= BITMAPF_REPEAT_Y;

	return plot.bitmap(x, y, width, height, c->bitmap, background_colour, flags);
}
Exemplo n.º 7
0
static void *nsico_get_internal(const struct content *c, void *context)
{
	nsico_content *ico = (nsico_content *) c;
	/* TODO: Pick best size for purpose.
	 *       Currently assumes it's for a URL bar. */
	struct bmp_image *bmp; 

	bmp = ico_find(ico->ico, 16, 16);
	if (bmp == NULL) {
		/* return error */
		LOG("Failed to select icon");
		return NULL;
	}

	if (bmp->decoded == false) {
		if (bmp_decode(bmp) != BMP_OK) {
			return NULL;
		} else {
			guit->bitmap->modified(bmp->bitmap);
		}
	}

	return bmp->bitmap;
}