From d0b78f4166a1503ce522944002b3aab035724cd9 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Mon, 23 May 2016 17:45:21 +0100 Subject: fz_pixmap revamp: add stride and make alpha optional fz_pixmaps now have an explicit stride value. By default no change from before, but code all copes with extra gaps at the end of the line. The alpha data in fz_pixmaps is no longer compulsory. mudraw: use rgb not rgba (ppmraw), cmyk not cmyka (pkmraw). Update halftone code to not expect alpha plane. Update PNG writing to cope with alpha less input. Also hide repeated params within the png output context. ARM code needs updating. --- platform/gl/gl-font.c | 2 +- platform/gl/gl-main.c | 6 ++++-- platform/x11/pdfapp.c | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'platform') diff --git a/platform/gl/gl-font.c b/platform/gl/gl-font.c index 58ead8ee..d6e1acc9 100644 --- a/platform/gl/gl-font.c +++ b/platform/gl/gl-font.c @@ -159,7 +159,7 @@ static struct glyph *lookup_glyph(fz_font *font, int gid, float *xp, float *yp) glEnd(); - pixmap = fz_render_glyph_pixmap(ctx, font, gid, &subpix_trm, NULL, NULL); + pixmap = fz_render_glyph_pixmap(ctx, font, gid, &subpix_trm, NULL); w = pixmap->w; h = pixmap->h; diff --git a/platform/gl/gl-main.c b/platform/gl/gl-main.c index 4a40d4ad..cc849a2f 100644 --- a/platform/gl/gl-main.c +++ b/platform/gl/gl-main.c @@ -227,7 +227,8 @@ void texture_from_pixmap(struct texture *tex, fz_pixmap *pix) { if (tex->w > max_texture_size || tex->h > max_texture_size) fz_warn(ctx, "texture size (%d x %d) exceeds implementation limit (%d)", tex->w, tex->h, max_texture_size); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex->w, tex->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, pix->samples); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex->w, tex->h, 0, GL_RGB, GL_UNSIGNED_BYTE, pix->samples); tex->s = 1; tex->t = 1; } @@ -237,8 +238,9 @@ void texture_from_pixmap(struct texture *tex, fz_pixmap *pix) int h2 = next_power_of_two(tex->h); if (w2 > max_texture_size || h2 > max_texture_size) fz_warn(ctx, "texture size (%d x %d) exceeds implementation limit (%d)", w2, h2, max_texture_size); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w2, h2, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, tex->w, tex->h, GL_RGBA, GL_UNSIGNED_BYTE, pix->samples); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, tex->w, tex->h, GL_RGB, GL_UNSIGNED_BYTE, pix->samples); tex->s = (float)tex->w / w2; tex->t = (float)tex->h / h2; } diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c index ab5b2e8d..fd1f6a1a 100644 --- a/platform/x11/pdfapp.c +++ b/platform/x11/pdfapp.c @@ -891,7 +891,7 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai else colorspace = app->colorspace; app->image = NULL; - app->image = fz_new_pixmap_with_bbox(app->ctx, colorspace, &ibounds); + app->image = fz_new_pixmap_with_bbox(app->ctx, colorspace, &ibounds, 1); fz_clear_pixmap_with_value(app->ctx, app->image, 255); if (app->page_list || app->annotations_list) { @@ -914,7 +914,7 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai colorspace = fz_device_gray(app->ctx); else colorspace = app->colorspace; - app->image = fz_new_pixmap_with_bbox(app->ctx, colorspace, &ibounds); + app->image = fz_new_pixmap_with_bbox(app->ctx, colorspace, &ibounds, app->image->alpha); app->duration = 0; new_trans = fz_page_presentation(app->ctx, app->page, &app->duration); if (new_trans) -- cgit v1.2.3