当前位置: 首页>>代码示例>>C++>>正文


C++ DviDevice::put_pixel方法代码示例

本文整理汇总了C++中DviDevice::put_pixel方法的典型用法代码示例。如果您正苦于以下问题:C++ DviDevice::put_pixel方法的具体用法?C++ DviDevice::put_pixel怎么用?C++ DviDevice::put_pixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DviDevice的用法示例。


在下文中一共展示了DviDevice::put_pixel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ROUND

void    mdvi_shrink_glyph_grey(DviContext *dvi, DviFont *font,
    DviFontChar *pk, DviGlyph *dest)
{
    int    rows_left, rows;
    int    cols_left, cols, init_cols;
    long    sampleval, samplemax;
    BmUnit    *old_ptr;
    void    *image;
    int    w, h;
    int    x, y;
    DviGlyph *glyph;
    BITMAP     *map;
    Ulong    *pixels;
    int    npixels;
    Ulong    colortab[2];
    int    hs, vs;
    DviDevice *dev;

    hs = dvi->params.hshrink;
    vs = dvi->params.vshrink;
    dev = &dvi->device;
    
    glyph = &pk->glyph;
    map = (BITMAP *)glyph->data;
    
    x = (int)glyph->x / hs;
    init_cols = (int)glyph->x - x * hs;
    if(init_cols <= 0)
        init_cols += hs;
    else
        x++;
    w = x + ROUND((int)glyph->w - glyph->x, hs);

    cols = (int)glyph->y + 1;
    y = cols / vs;
    rows = cols - y * vs;
    if(rows <= 0) {
        rows += vs;
        y--;
    }
    h = y + ROUND((int)glyph->h - cols, vs) + 1;
    ASSERT(w && h);
    
    /* before touching anything, do this */
    image = dev->create_image(dev->device_data, w, h, BITMAP_BITS);
    if(image == NULL) {
        mdvi_shrink_glyph(dvi, font, pk, dest);
        return;
    }
    
    /* save these colors */
    pk->fg = MDVI_CURRFG(dvi);
    pk->bg = MDVI_CURRBG(dvi);
    
    samplemax = vs * hs;
    npixels = samplemax + 1;
    pixels = get_color_table(&dvi->device, npixels, pk->fg, pk->bg,
            dvi->params.gamma, dvi->params.density);
    if(pixels == NULL) {
        npixels = 2;
        colortab[0] = pk->fg;
        colortab[1] = pk->bg;
        pixels = &colortab[0];
    }
    
    /* setup the new glyph */
    dest->data = image;
    dest->x = x;
    dest->y = glyph->y / vs;
    dest->w = w;
    dest->h = h;

    y = 0;
    old_ptr = map->data;
    rows_left = glyph->h;

    while(rows_left && y < h) {
        x = 0;
        if(rows > rows_left)
            rows = rows_left;
        cols_left = glyph->w;
        cols = init_cols;
        while(cols_left && x < w) {
            if(cols > cols_left)
                cols = cols_left;
            sampleval = do_sample(old_ptr, map->stride,
                glyph->w - cols_left, cols, rows);
            /* scale the sample value by the number of grey levels */
            if(npixels - 1 != samplemax)
                sampleval = ((npixels-1) * sampleval) / samplemax;
            ASSERT(sampleval < npixels);
            dev->put_pixel(image, x, y, pixels[sampleval]);
            cols_left -= cols;
            cols = hs;
            x++;
        }
        for(; x < w; x++)
            dev->put_pixel(image, x, y, pixels[0]);
        old_ptr = bm_offset(old_ptr, rows * map->stride);
        rows_left -= rows;
//.........这里部分代码省略.........
开发者ID:yourealwaysbe,项目名称:zathura-dvi-mdvi,代码行数:101,代码来源:bitmap.c


注:本文中的DviDevice::put_pixel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。