Home| base |src.lib|graphic|ps| PostScriptImage Index

PostScriptImage

Syntax
int PostScriptImage(struct PostScript *ptr, struct PostScriptMatrix *matrix,struct FrameBuffer *img, unsigned char mask, float x,float y, struct PostScriptClip *clip);
Header
base/rps.h
Library
rps
Description

The PostScriptImage function plots a bitmap image.

The argument ptr is a pointer to the PostScript control structure. The argument matrix is an optional transformation matrix that can be applied to the bitmap. If this is set to a NULL pointer then no transformation is applied.

The bitmap image is pointed to by the argument img.

The argument mask defines which color channels are active. Setting this argument to (0x0f) will output the color to all four channels. The most significant bit controls the alpha channel and the least significant bit controls the blue channel.

The position of the top-left hand corner of the bitmap is given by the arguments x, and y.

The clipping polygon is given by the argument clip. If this is set to a NULL pointer, no clipping is performed.

Returns
Returns zero on success. On error, (-1) is returned.
Errors
On error, (-1) is returned.
Example
PostScriptImage
Source Code: PostScriptImage.c

/* PostScriptImage
   ===============
   Author: R.J.Barnes
 Copyright (c) 2012 The Johns Hopkins University/Applied Physics Laboratory

This file is part of the Radar Software Toolkit (RST).

RST is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

Modifications:




#include <stdio.h>
#include <stdlib.h>
#include "rfbuffer.h"
#include "rps.h"

int stream(char *buf,int sze,void *data) {
  FILE *fp;
  fp=(FILE *) data;
  fwrite(buf,sze,1,stdout);
  return 0;
} 


int main(int argc,char *argv[]) {

  struct FrameBuffer *img;
  struct PostScript *ps=NULL;

  float wdt=400,hgt=400;
  float xoff=50,yoff=50;

  int x,y;

  unsigned int bgcol=0xffffffff;
  unsigned int fgcol=0xff000000;


  img=FrameBufferMake("FrameBuffer",10,10,24);
  
  FrameBufferClear(img,bgcol,0x0f);

  FrameBufferEllipse(img,NULL,5,5,5,5,0,fgcol,0x0f,0,NULL,NULL);

  ps=PostScriptMake();
  PostScriptSetText(ps,stream,stdout);   
  PostScriptMakeDocument(ps,xoff,yoff,wdt,hgt,0);
  PostScriptMakePlot(ps);

  for (x=0;x<wdt;x+=10) {
    for (y=0;y<hgt;y+=10) {
      PostScriptImage(ps,NULL,img,0x0f,x,y,NULL);
    }
  }

  PostScriptEndPlot(ps);
  PostScriptEndDocument(ps);
  return 0;
}