int density)
{
double frac;
- GdkColor color, color_fg, color_bg;
+ GdkColor color, color_fg;
int i, n;
-
- color_bg.red = (bg >> 16) & 0xff;
- color_bg.green = (bg >> 8) & 0xff;
- color_bg.blue = (bg >> 0) & 0xff;
+ unsigned int alpha;
color_fg.red = (fg >> 16) & 0xff;
color_fg.green = (fg >> 8) & 0xff;
pow ((double)i / n, 1 / gamma) :
1 - pow ((double)(n - i) / n, -gamma);
- color.red = frac * ((double)color_fg.red - color_bg.red) + color_bg.red;
- color.green = frac * ((double)color_fg.green - color_bg.green) + color_bg.green;
- color.blue = frac * ((double)color_fg.blue - color_bg.blue) + color_bg.blue;
-
- pixels[i] = (color.red << 16) + (color.green << 8) + color.blue + 0xff000000;
+ color.red = frac * color_fg.red;
+ color.green = frac * color_fg.green;
+ color.blue = frac * color_fg.blue;
+ alpha = frac * 0xFF;
+
+ pixels[i] = (alpha << 24) + (color.red << 16) + (color.green << 8) + color.blue;
}
return npixels;
Uint height,
Uint bpp)
{
- return cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height);
+ return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
}
static void
rowstride = cairo_image_surface_get_stride (surface);
p = (guint32*) (cairo_image_surface_get_data (surface) + y * rowstride + x * 4);
+ /* per cairo docs, must flush before modifying outside of cairo */
+ cairo_surface_flush(surface);
*p = color;
}
memset (pixels, 0xff, page_height * rowstride);
surface = cairo_image_surface_create_for_data (pixels,
- CAIRO_FORMAT_RGB24,
+ CAIRO_FORMAT_ARGB32,
page_width, page_height,
rowstride);
cairo_surface_set_user_data (surface, &key,
(a), (b) > 0 ? '+' : '-', \
(b) > 0 ? (b) : -(b), (c)
-/*
- * Draw rules with some sort of antialias support. Usefult for high-rate
- * scale factors.
- */
-
static void draw_shrink_rule (DviContext *dvi, int x, int y, Uint w, Uint h, int f)
{
- int hs, vs, npixels;
Ulong fg, bg;
- Ulong *pixels;
-
- hs = dvi->params.hshrink;
- vs = dvi->params.vshrink;
+
fg = dvi->curr_fg;
bg = dvi->curr_bg;
- if (MDVI_ENABLED(dvi, MDVI_PARAM_ANTIALIASED)) {
- npixels = vs * hs + 1;
- pixels = get_color_table(&dvi->device, npixels, bg, fg,
- dvi->params.gamma, dvi->params.density);
-
- if (pixels) {
- int color;
-
- /* Lines with width 1 should be perfectly visible
- * in shrink about 15. That is the reason of constant
- */
-
- color = (pow (vs / h * hs, 2) + pow (hs / w * vs, 2)) / 225;
- if (color < npixels) {
- fg = pixels[color];
- } else {
- fg = pixels[npixels - 1];
- }
- }
- }
-
mdvi_push_color (dvi, fg, bg);
dvi->device.draw_rule(dvi, x, y, w, h, f);
mdvi_pop_color (dvi);