Example #1
0
void
h_update_hyperlinks(Widget w, Pixel pix)
{
    const char *name = XtName(w);
    int type = 0;

    if (strcmp(name, Xdvi_UNVISITED_LINKS_BTN) == 0) {
	type = 1;
    }
    else if (strcmp(name, Xdvi_VISITED_LINKS_BTN) == 0) {
	type = 2;
    }

    /* fprintf(stderr, "WIDGET: |%s|; type: %d\n", name, type); */

    if (type != 0) {
	GC new_gc = set_or_make_gc(NULL, GXcopy, pix, resource.back_Pixel);
	GC old_gc;
	double r, g, b;
	double factor = 65535.0;
	XColor color;

	pixel_to_color(pix, &color, DISP, G_colormap);
	r = color.red / factor;
	g = color.green / factor;
	b = color.blue / factor;

	if (type == 1) {
	    old_gc = globals.gc.linkcolor;
	    sprintf(g_link_color_rgb, "push rgb %.2f %.2f %.2f", r, g, b);
	}
	else {
	    old_gc = globals.gc.visited_linkcolor;
	    sprintf(g_visited_link_color_rgb, "push rgb %.2f %.2f %.2f", r, g, b);
	}

	if (type == 1) {
	    globals.gc.linkcolor = new_gc;
	    XFreeGC(XtDisplay(w), old_gc);
	}
	else {
	    globals.gc.visited_linkcolor = new_gc;
	    XFreeGC(XtDisplay(w), old_gc);
	}
	/* update display */
	globals.ev.flags |= EV_NEWPAGE;
	XFlush(DISP);
    }
}
	Image TGAReader::read_image_data()
	{
		Image image(header.image.width, header.image.height);
		std::vector<std::uint8_t> row(bytes_per_pixel() * header.image.width);

		for (unsigned int y = 0; y < header.image.height; y++)
		{
			if (header.run_length_encoded)
				read_run_length_encoded(row);
			else
				read(row);

			for (unsigned int x = 0; x < header.image.width; x++)
				image.write_pixel(x_to_image_x(x), y_to_image_y(y), pixel_to_color(row, x));
		}

		return image;
	}