本文整理汇总了C++中DviDevice::image_done方法的典型用法代码示例。如果您正苦于以下问题:C++ DviDevice::image_done方法的具体用法?C++ DviDevice::image_done怎么用?C++ DviDevice::image_done使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DviDevice
的用法示例。
在下文中一共展示了DviDevice::image_done方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ROUND
//.........这里部分代码省略.........
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;
rows = vs;
y++;
}
for(; y < h; y++) {
for(x = 0; x < w; x++)
dev->put_pixel(image, x, y, pixels[0]);
}
dev->image_done(image);
DEBUG((DBG_BITMAPS, "shrink_glyph_grey: (%dw,%dh,%dx,%dy) -> (%dw,%dh,%dx,%dy)\n",
glyph->w, glyph->h, glyph->x, glyph->y,
dest->w, dest->h, dest->x, dest->y));
}