MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / PSL_plotbitimage

Function PSL_plotbitimage

src/postscriptlight.c:3755–3792  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3753}
3754
3755int PSL_plotbitimage (struct PSL_CTRL *PSL, double x, double y, double xsize, double ysize, int justify, unsigned char *buffer, int nx, int ny, double f_rgb[], double b_rgb[]) {
3756 /* Plots a 1-bit image or imagemask.
3757 * x, y : Position of image (in units)
3758 * xsize, ysize : image size in units (if 0, adjust to keep the original aspect ratio)
3759 * justify : Indicate which corner x,y refers to (see graphic)
3760 * buffer : Image bit buffer
3761 * nx, ny : Size of image (in pixels)
3762 * f_rgb : Foreground color for 1 bits (if f_rgb[0] < 0, make transparent)
3763 * b_rgb : Background color for 0 bits (if b_rgb[0] < 0, make transparent)
3764 *
3765 * 9 10 11
3766 * |----------------|
3767 * 5 <image> 7
3768 * |----------------|
3769 * 1 2 3
3770 */
3771 int inv;
3772
3773 /* If one of [xy]size is 0, keep the aspect ratio */
3774 if (PSL_eq (xsize, 0.0)) xsize = (ysize * nx) / ny;
3775 if (PSL_eq (ysize, 0.0)) ysize = (xsize * ny) / nx;
3776
3777 /* Correct origin (x,y) in case of justification */
3778 if (justify > 1) { /* Move the new origin so (0,0) is lower left of box */
3779 x -= 0.5 * ((justify + 3) % 4) * xsize;
3780 y -= 0.5 * (int)(justify / 4) * ysize;
3781 }
3782
3783 PSL_comment (PSL, "Start of 1-bit image\n");
3784 PSL_command (PSL, "V N %d %d T %d %d scale", psl_ix(PSL, x), psl_iy(PSL, y), psl_iz (PSL, xsize), psl_iz (PSL, ysize));
3785 inv = psl_bitimage_cmap (PSL, f_rgb, b_rgb) % 2;
3786 PSL_command (PSL, "\n<< /ImageType 1 /Decode [%d %d] ", inv, 1-inv);
3787 psl_stream_dump (PSL, buffer, nx, ny, 1, PSL->internal.compress, PSL_ASCII85, (int)(f_rgb[0] < 0.0 || b_rgb[0] < 0.0));
3788
3789 PSL_command (PSL, "U\n");
3790 PSL_comment (PSL, "End of 1-bit image\n");
3791 return (PSL_NO_ERROR);
3792}
3793
3794int PSL_endclipping (struct PSL_CTRL *PSL, int n) {
3795 /* n > 0 means restore clipping n times

Callers 5

PSL_plotbitimage_Function · 0.85
GMT_psimageFunction · 0.85
GMT_pssegyFunction · 0.85
GMT_pssegyzFunction · 0.85

Calls 7

PSL_commentFunction · 0.85
PSL_commandFunction · 0.85
psl_ixFunction · 0.85
psl_iyFunction · 0.85
psl_izFunction · 0.85
psl_bitimage_cmapFunction · 0.85
psl_stream_dumpFunction · 0.85

Tested by

no test coverage detected