Beispiel #1
0
static void read_scale_img(image * a)
{
    image_dict *ad;
    if (a == NULL) {
        luaL_error(Luas, "the image scaler needs a valid image");
    } else {
        ad = img_dict(a);
        if (a == NULL) {
            luaL_error(Luas, "the image scaler needs a valid dictionary");
        } else {
            if (img_state(ad) == DICT_NEW) {
                if (img_type(ad) == IMG_TYPE_PDFSTREAM)
                    check_pdfstream_dict(ad);
                else {
                    read_img(ad);
                }
            }
            if ((img_type(ad) == IMG_TYPE_NONE) || (img_state(ad) == DICT_NEW)) {
                normal_warning("image","don't rely on the image data to be okay");
                img_width(a) = 0;
                img_height(a) = 0;
                img_depth(a) = 0;
            } else if (is_wd_running(a) || is_ht_running(a) || is_dp_running(a)) {
                img_dimen(a) = scale_img(ad, img_dimen(a), img_transform(a));
            }
        }
    }
}
Beispiel #2
0
static void read_scale_img(image * a)
{
    image_dict *ad;
    assert(a != NULL);
    ad = img_dict(a);
    assert(ad != NULL);
    if (img_state(ad) == DICT_NEW) {
        if (img_type(ad) == IMG_TYPE_PDFSTREAM)
            check_pdfstream_dict(ad);
        else {
            fix_pdf_minorversion(static_pdf);
            read_img(static_pdf,
                     ad, pdf_minor_version, pdf_inclusion_errorlevel);
        }
    }
    if (is_wd_running(a) || is_ht_running(a) || is_dp_running(a))
        img_dimen(a) = scale_img(ad, img_dimen(a), img_transform(a));
}
Beispiel #3
0
void vf_out_image(PDF pdf, unsigned i)
{
    image *a, **aa;
    image_dict *ad;
    lua_State *L = Luas;        /* ... */
    lua_rawgeti(L, LUA_GLOBALSINDEX, (int) i);  /* image ... */
    aa = (image **) luaL_checkudata(L, -1, TYPE_IMG);
    a = *aa;
    ad = img_dict(a);
    assert(ad != NULL);
    setup_image(pdf, a, WR_VF_IMG);     /* image ... */
    place_img(pdf, ad, img_dimen(a), img_transform(a));
    lua_pop(L, 1);              /* ... */
}
Beispiel #4
0
void vf_out_image(PDF pdf, unsigned i)
{
    image *a, **aa;
    image_dict *ad;
    lua_rawgeti(Luas, LUA_REGISTRYINDEX, (int) i);
    aa = (image **) luaL_checkudata(Luas, -1, TYPE_IMG);
    a = *aa;
    ad = img_dict(a);
    if (ad == NULL) {
        luaL_error(Luas, "invalid image dictionary");
    }
    setup_image(pdf, a, WR_VF_IMG);
    place_img(pdf, ad, img_dimen(a), img_transform(a));
    lua_pop(Luas, 1);
}
Beispiel #5
0
void scan_pdfrefximage(PDF pdf)
{
    /*tex One could scan transform as well. */
    int transform = 0;
    /*tex Begin of experiment. */
    int open = 0;
    /*tex End of experiment. */
    image_dict *idict;
    /*tex This scans |<rule spec>| to |alt_rule|. */
    scaled_whd alt_rule, dim;
    alt_rule = scan_alt_rule();
    /*tex Begin of experiment. */
    if (scan_keyword("keepopen")) {
        open = 1;
    }
    /*tex End of experiment. */
    scan_int();
    check_obj_type(pdf, obj_type_ximage, cur_val);
    tail_append(new_rule(image_rule));
    idict = idict_array[obj_data_ptr(pdf, cur_val)];
    /*tex Begin of experiment, */
    if (open) {
        /*tex So we keep the original value when no close is given. */
        idict->keepopen = 1;
    }
    /*tex End of experiment. */
    if (img_state(idict) == DICT_NEW) {
        normal_warning("image","don't rely on the image data to be okay");
        width(tail_par) = 0;
        height(tail_par) = 0;
        depth(tail_par) = 0;
    } else {
        if (alt_rule.wd != null_flag || alt_rule.ht != null_flag || alt_rule.dp != null_flag) {
            dim = scale_img(idict, alt_rule, transform);
        } else {
            dim = scale_img(idict, img_dimen(idict), img_transform(idict));
        }
        width(tail_par) = dim.wd;
        height(tail_par) = dim.ht;
        depth(tail_par) = dim.dp;
        rule_transform(tail_par) = transform;
        rule_index(tail_par) = img_index(idict);
    }
}
Beispiel #6
0
void scan_pdfximage(PDF pdf)
{
    scaled_whd alt_rule;
    image_dict *idict;
    int transform = 0, page = 1, pagebox, colorspace = 0;
    char *named = NULL, *attr = NULL, *file_name = NULL, *user = NULL, *owner = NULL, *visible = NULL;
    alt_rule = scan_alt_rule();
    if (scan_keyword("attr")) {
        scan_toks(false, true);
        attr = tokenlist_to_cstring(def_ref, true, NULL);
        delete_token_ref(def_ref);
    }
    if (scan_keyword("named")) {
        scan_toks(false, true);
        if (0) {
            named = tokenlist_to_cstring(def_ref, true, NULL);
            page = 0;
        } else {
            normal_warning("pdf backend","named pages are not supported, using page 1");
            page = 1;
        }
        delete_token_ref(def_ref);
    } else if (scan_keyword("page")) {
        scan_int();
        page = cur_val;
    }
    if (scan_keyword("userpassword")) {
        scan_toks(false, true);
        user = tokenlist_to_cstring(def_ref, true, NULL);
        delete_token_ref(def_ref);
    }
    if (scan_keyword("ownerpassword")) {
        scan_toks(false, true);
        owner = tokenlist_to_cstring(def_ref, true, NULL);
        delete_token_ref(def_ref);
    }
    if (scan_keyword("visiblefilename")) {
        scan_toks(false, true);
        visible = tokenlist_to_cstring(def_ref, true, NULL);
        delete_token_ref(def_ref);
    }
    if (scan_keyword("colorspace")) {
        scan_int();
        colorspace = cur_val;
    }
    pagebox = scan_pdf_box_spec();
    if (pagebox == PDF_BOX_SPEC_NONE) {
        pagebox = pdf_pagebox;
        if (pagebox == PDF_BOX_SPEC_NONE)
            pagebox = PDF_BOX_SPEC_CROP;
    }
    scan_toks(false, true);
    file_name = tokenlist_to_cstring(def_ref, true, NULL);
    if (file_name == NULL) {
        normal_error("pdf backend","no image filename given");
    }
    delete_token_ref(def_ref);
    idict = read_image(file_name, page, named, colorspace, pagebox, user, owner, visible);
    img_attr(idict) = attr;
    img_dimen(idict) = alt_rule;
    img_transform(idict) = transform;
    last_saved_image_index = img_objnum(idict);
    last_saved_image_pages = img_totalpages(idict);
}