コード例 #1
0
ファイル: htmltable.c プロジェクト: Chaduke/bah.mod
/* size_html_img:
 */
static int size_html_img(htmlimg_t * img, htmlenv_t * env)
{
    box b;
    int rv;

    b.LL.x = b.LL.y = 0;
    b.UR = gvusershape_size(env->g, img->src);
    if ((b.UR.x == -1) && (b.UR.y == -1)) {
	rv = 1;
	b.UR.x = b.UR.y = 0;
	agerr(AGERR, "No or improper image file=\"%s\"\n", img->src);
    } else {
	rv = 0;
	GD_has_images(env->g) = TRUE;
    }

    img->box = b;
    return rv;
}
コード例 #2
0
ファイル: gdgen.c プロジェクト: Goettsch/game-editor
static void gd_begin_graph(GVC_t * gvc, graph_t * g, box bb, point pb)
{
    char *bgcolor_str = NULL;
    char *truecolor_str;
    bool truecolor_p = FALSE;	/* try to use cheaper paletted mode */
    bool bg_transparent_p = FALSE;
    int bgcolor;

    external_surface = gvc->job->external_surface;

    init1_gd(gvc, g, bb, pb);

    if (external_surface) {
        im = (gdImagePtr)gvc->job->surface;
    } else {
        truecolor_str = agget(g, "truecolor");	/* allow user to force truecolor */
        bgcolor_str = agget(g, "bgcolor");

        if (truecolor_str && truecolor_str[0])
            truecolor_p = mapbool(truecolor_str);

        if (bgcolor_str && strcmp(bgcolor_str, "transparent") == 0) {
            bg_transparent_p = TRUE;
            if (is_format_truecolor_capable(Output_lang))
                truecolor_p = TRUE;	/* force truecolor */
        }

        if (GD_has_images(g))
            truecolor_p = TRUE;	/* force truecolor */

        if (truecolor_p) {
            if (Verbose)
                fprintf(stderr, "%s: allocating a %dK TrueColor GD image\n",
                        CmdName, ROUND(Viewport.x * Viewport.y * 4 / 1024.));
            im = gdImageCreateTrueColor(Viewport.x, Viewport.y);
        } else {
            if (Verbose)
                fprintf(stderr, "%s: allocating a %dK PaletteColor GD image\n",
                        CmdName, ROUND(Viewport.x * Viewport.y / 1024.));
            im = gdImageCreate(Viewport.x, Viewport.y);
        }
        if (!im) {
            agerr(AGERR, "gdImageCreate returned NULL. Malloc problem?\n");
            return;
        }
    }

    init2_gd(im);

    if (! external_surface) {
        if (bgcolor_str && bgcolor_str[0])
            if (bg_transparent_p)
                bgcolor = transparent;
            else
                bgcolor = gd_resolve_color(bgcolor_str);
        else
            bgcolor = white;

        cstk[0].fillcolor = bgcolor;

        /* Blending must be off to lay a transparent bgcolor.
           Nothing to blend with anyway. */
        gdImageAlphaBlending(im, FALSE);

        gdImageFill(im, im->sx / 2, im->sy / 2, bgcolor);

        /* Blend everything else together,
           especially fonts over non-transparent backgrounds */
        gdImageAlphaBlending(im, TRUE);
    }

#ifdef MYTRACE
    fprintf(stderr, "gd_begin_graph\n");
#endif
}