void pdfapp_inverthit(pdfapp_t *app) { fz_bbox hitbox, bbox; fz_matrix ctm; int i; if (app->hit < 0) return; hitbox = fz_empty_bbox; ctm = pdfapp_viewctm(app); for (i = app->hit; i < app->hit + app->hitlen; i++) { bbox = bboxcharat(app->page_text, i); if (fz_is_empty_rect(bbox)) { if (!fz_is_empty_rect(hitbox)) pdfapp_invert(app, fz_transform_bbox(ctm, hitbox)); hitbox = fz_empty_bbox; } else { hitbox = fz_union_bbox(hitbox, bbox); } } if (!fz_is_empty_rect(hitbox)) pdfapp_invert(app, fz_transform_bbox(ctm, hitbox)); }
void winblit() { int image_w = fz_pixmap_width(gapp.ctx, gapp.image); int image_h = fz_pixmap_height(gapp.ctx, gapp.image); int image_n = fz_pixmap_components(gapp.ctx, gapp.image); unsigned char *samples = fz_pixmap_samples(gapp.ctx, gapp.image); int x0 = gapp.panx; int y0 = gapp.pany; int x1 = gapp.panx + image_w; int y1 = gapp.pany + image_h; RECT r; if (gapp.image) { if (gapp.iscopying || justcopied) { pdfapp_invert(&gapp, &gapp.selr); justcopied = 1; } pdfapp_inverthit(&gapp); dibinf->bmiHeader.biWidth = image_w; dibinf->bmiHeader.biHeight = -image_h; dibinf->bmiHeader.biSizeImage = image_h * 4; if (image_n == 2) { int i = image_w * image_h; unsigned char *color = malloc(i*4); unsigned char *s = samples; unsigned char *d = color; for (; i > 0 ; i--) { d[2] = d[1] = d[0] = *s++; d[3] = *s++; d += 4; } SetDIBitsToDevice(hdc, gapp.panx, gapp.pany, image_w, image_h, 0, 0, 0, image_h, color, dibinf, DIB_RGB_COLORS); free(color); } if (image_n == 4) { SetDIBitsToDevice(hdc, gapp.panx, gapp.pany, image_w, image_h, 0, 0, 0, image_h, samples, dibinf, DIB_RGB_COLORS); } pdfapp_inverthit(&gapp); if (gapp.iscopying || justcopied) { pdfapp_invert(&gapp, &gapp.selr); justcopied = 1; } } /* Grey background */ r.top = 0; r.bottom = gapp.winh; r.left = 0; r.right = x0; FillRect(hdc, &r, bgbrush); r.left = x1; r.right = gapp.winw; FillRect(hdc, &r, bgbrush); r.left = 0; r.right = gapp.winw; r.top = 0; r.bottom = y0; FillRect(hdc, &r, bgbrush); r.top = y1; r.bottom = gapp.winh; FillRect(hdc, &r, bgbrush); /* Drop shadow */ r.left = x0 + 2; r.right = x1 + 2; r.top = y1; r.bottom = y1 + 2; FillRect(hdc, &r, shbrush); r.left = x1; r.right = x1 + 2; r.top = y0 + 2; r.bottom = y1; FillRect(hdc, &r, shbrush); winblitsearch(); }
static void winblit(pdfapp_t *app) { int image_w = fz_pixmap_width(gapp.ctx, gapp.image); int image_h = fz_pixmap_height(gapp.ctx, gapp.image); int image_n = fz_pixmap_components(gapp.ctx, gapp.image); unsigned char *image_samples = fz_pixmap_samples(gapp.ctx, gapp.image); int x0 = gapp.panx; int y0 = gapp.pany; int x1 = gapp.panx + image_w; int y1 = gapp.pany + image_h; XSetForeground(xdpy, xgc, xbgcolor.pixel); fillrect(0, 0, x0, gapp.winh); fillrect(x1, 0, gapp.winw - x1, gapp.winh); fillrect(0, 0, gapp.winw, y0); fillrect(0, y1, gapp.winw, gapp.winh - y1); XSetForeground(xdpy, xgc, xshcolor.pixel); fillrect(x0+2, y1, image_w, 2); fillrect(x1, y0+2, 2, image_h); if (gapp.iscopying || justcopied) { pdfapp_invert(&gapp, &gapp.selr); justcopied = 1; } pdfapp_inverthit(&gapp); if (image_n == 4) ximage_blit(xwin, xgc, x0, y0, image_samples, 0, 0, image_w, image_h, image_w * image_n); else if (image_n == 2) { int i = image_w*image_h; unsigned char *color = malloc(i*4); if (color) { unsigned char *s = image_samples; unsigned char *d = color; for (; i > 0 ; i--) { d[2] = d[1] = d[0] = *s++; d[3] = *s++; d += 4; } ximage_blit(xwin, xgc, x0, y0, color, 0, 0, image_w, image_h, image_w * 4); free(color); } } pdfapp_inverthit(&gapp); if (gapp.iscopying || justcopied) { pdfapp_invert(&gapp, &gapp.selr); justcopied = 1; } winblitsearch(app); if (showingpage) { char buf[42]; snprintf(buf, sizeof buf, "Page %d/%d", gapp.pageno, gapp.pagecount); windrawstringxor(&gapp, 10, 20, buf); } }
static void winblit(pdfapp_t *app) { int x0 = gapp.panx; int y0 = gapp.pany; int x1 = gapp.panx + gapp.image->w; int y1 = gapp.pany + gapp.image->h; XSetForeground(xdpy, xgc, xbgcolor.pixel); fillrect(0, 0, x0, gapp.winh); fillrect(x1, 0, gapp.winw - x1, gapp.winh); fillrect(0, 0, gapp.winw, y0); fillrect(0, y1, gapp.winw, gapp.winh - y1); XSetForeground(xdpy, xgc, xshcolor.pixel); fillrect(x0+2, y1, gapp.image->w, 2); fillrect(x1, y0+2, 2, gapp.image->h); if (gapp.iscopying || justcopied) { pdfapp_invert(&gapp, gapp.selr); justcopied = 1; } pdfapp_inverthit(&gapp); if (gapp.image->n == 4) ximage_blit(xwin, xgc, x0, y0, gapp.image->samples, 0, 0, gapp.image->w, gapp.image->h, gapp.image->w * gapp.image->n); else if (gapp.image->n == 2) { int i = gapp.image->w*gapp.image->h; unsigned char *color = malloc(i*4); if (color != NULL) { unsigned char *s = gapp.image->samples; unsigned char *d = color; for (; i > 0 ; i--) { d[2] = d[1] = d[0] = *s++; d[3] = *s++; d += 4; } ximage_blit(xwin, xgc, x0, y0, color, 0, 0, gapp.image->w, gapp.image->h, gapp.image->w * 4); free(color); } } pdfapp_inverthit(&gapp); if (gapp.iscopying || justcopied) { pdfapp_invert(&gapp, gapp.selr); justcopied = 1; } winblitsearch(app); }