DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T g

⟦fb899cb01⟧ TextFile

    Length: 4010 (0xfaa)
    Types: TextFile
    Names: »gspaint.c«

Derivation

└─⟦a05ed705a⟧ Bits:30007078 DKUUG GNU 2/12/89
    └─⟦ff23ba0e6⟧ »./ghostscript-1.3.tar.Z« 
        └─⟦a24a58cd3⟧ 
            └─⟦this⟧ »gspaint.c« 

TextFile

/* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
   Distributed by Free Software Foundation, Inc.

This file is part of Ghostscript.

Ghostscript is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
to anyone for the consequences of using it or for whether it serves any
particular purpose or works at all, unless he says so in writing.  Refer
to the Ghostscript General Public License for full details.

Everyone is granted permission to copy, modify and redistribute
Ghostscript, but only under the conditions described in the Ghostscript
General Public License.  A copy of this license is supposed to have been
given to you along with Ghostscript so you can know your rights and
responsibilities.  It should be in a file named COPYING.  Among other
things, the copyright notice and this notice must be preserved on all
copies.  */

/* gspaint.c */
/* Painting procedures for GhostScript library */
#include "gx.h"
#include "malloc_.h"
#include "gxfixed.h"
#include "gxmatrix.h"			/* for gs_state */
#include "gspaint.h"
#include "gzpath.h"
#include "gzstate.h"
#include "gzdevice.h"
#include "gzcolor.h"
#include "gximage.h"

/* Erase the page */
int
gs_erasepage(gs_state *pgs)
{	device *pdev = pgs->device;
	gx_device *dev = pdev->info;
	(*dev->procs->fill_rectangle)(dev, 0, 0, dev->width, dev->height, pdev->white);
	return 0;
}

/* Fill using the winding number rule */
int
gs_fill(gs_state *pgs)
{	int code;
	gx_color_render(pgs->color, pgs);
	code = gx_fill_path(pgs->path, pgs->color, pgs, gx_rule_winding_number);
	if ( !code ) gs_newpath(pgs);
	return code;
}

/* Fill using the even/odd rule */
int
gs_eofill(gs_state *pgs)
{	int code;
	gx_color_render(pgs->color, pgs);
	code = gx_fill_path(pgs->path, pgs->color, pgs, gx_rule_even_odd);
	if ( !code ) gs_newpath(pgs);
	return code;
}

/* Stroke the current path */
int
gs_stroke(gs_state *pgs)
{	int code;
	gx_color_render(pgs->color, pgs);
	code = gx_stroke_fill(pgs->path, pgs);
	if ( !code ) gs_newpath(pgs);
	return code;
}

/* Compute the stroked outline of the current path */

int
gs_strokepath(gs_state *pgs)
{	gx_path spath;
	int code;
	gx_path_init(&spath, &pgs->memory_procs);
	code = gx_stroke_add(pgs->path, &spath, pgs);
	if ( code < 0 ) return code;
	gx_path_release(pgs->path);
	*pgs->path = spath;
	return 0;
}

/* Render a sampled image */
int
gs_image(gs_state *pgs, int width, int height, int bps,
  gs_matrix *pmat, int (*proc)(P2(byte **, int *)))
{	gs_image_enum ienum;
	int code;
	byte *data;
	int size;
	if ( (code = gs_image_init(&ienum, pgs, width, height, bps, pmat)) < 0 )
		return code;
	while ( (code = (*proc)(&data, &size)) == 0 )
	   {	if ( (code = gs_image_next(&ienum, data, size)) != 0 )
			return (code < 0 ? code : 0);
	   }
	return code;
}
int
gs_image_data(gs_state *pgs, int width, int height, int bps,
  gs_matrix *pmat, byte *data)
{	gs_image_enum ienum;
	int code;
	uint size = (((uint)width * bps + 7) >> 3) * (uint)height;
	if ( (code = gs_image_init(&ienum, pgs, width, height, bps, pmat)) < 0 )
		return code;
	code = gs_image_next(&ienum, data, size);
	return (code < 0 ? code : 0);
}

/* Render a mask */
int
gs_imagemask(gs_state *pgs, int width, int height, int invert,
  gs_matrix *pmat, int (*proc)(P2(byte **, int *)))
{	gs_image_enum ienum;
	int code;
	byte *data;
	int size;
	if ( (code = gs_imagemask_init(&ienum, pgs, width, height, invert, pmat)) < 0 )
		return code;
	while ( (code = (*proc)(&data, &size)) == 0 )
	   {	if ( (code = gs_image_next(&ienum, data, size)) != 0 )
			return (code < 0 ? code : 0);
	   }
	return code;
}
int
gs_imagemask_data(gs_state *pgs, int width, int height, int invert,
  gs_matrix *pmat, byte *data)
{	gs_image_enum ienum;
	int code;
	uint size = (((uint)width + 7) >> 3) * (uint)height;
	if ( (code = gs_imagemask_init(&ienum, pgs, width, height, invert, pmat)) < 0 )
		return code;
	code = gs_image_next(&ienum, data, size);
	return (code < 0 ? code : 0);
}