Example #1
0
int
Graphics_DrawRect(SDL_Surface *s, SDL_Rect *rect, Uint32 color)
{
    Uint8	bpp = s->format->BytesPerPixel;
    Uint8	*p = XYTOPTR(s, rect->x + 1, rect->y, bpp);

    Uint32	d;

    GENERIC_LOCK(s);

    if (rect->w > 2) {
        d = (rect->h - 1)*s->pitch;

        for (Uint16 w = rect->w - 2; w; w--, p += bpp) {
            SETPIXEL(p, bpp, color);
            SETPIXEL(p + d, bpp, color);
        }
    }

    d = (rect->w - 1)*bpp;
    for (Uint16 h = rect->h; h; h--, p += s->pitch) {
        SETPIXEL(p, bpp, color);
        SETPIXEL(p - d, bpp, color);
    }

    GENERIC_UNLOCK(s);
}
Example #2
0
// store all preference locally
extern "C" G_MODULE_EXPORT void store_preferences (GtkObject *object, gpointer user_data) {
	TS keus;

	// get color and fill the pixel values
    gtk_color_button_get_color(GTK_COLOR_BUTTON(colorbutton1),  &lijnkleur);
    SETPIXEL(lijnkleur);
    gtk_color_button_get_color(GTK_COLOR_BUTTON(colorbutton2),  &rasterkleur);
    SETPIXEL(rasterkleur);

	// get some conf settings that are not set already
    conf.opacity 		= gtk_adjustment_get_value(GTK_ADJUSTMENT(opacity));
    conf.font 			= strdup(gtk_font_button_get_font_name(GTK_FONT_BUTTON(fontbutton)));
    conf.device			= gtk_combo_box_get_active_text (GTK_COMBO_BOX(combo));
    conf.speed 			= gtk_adjustment_get_value(GTK_ADJUSTMENT(speed));
    conf.lijnkleur		= lijnkleur.pixel;
    conf.rasterkleur	= rasterkleur.pixel;
    conf.raster 		= GTK_TOGGLE_BUTTON(checkbutton1)->active;
    conf.tips			= GTK_TOGGLE_BUTTON(checkbutton8)->active;
    conf.speech			= GTK_TOGGLE_BUTTON(checkbutton9)->active;
    conf.voice			= gtk_combo_box_get_active(GTK_COMBO_BOX(combobox1));

    // get conf.keymode[6].mode (the default mode)
	mode = 0;
	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(modebits[0].check)))
		mode |= (GB1|GB2);
	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(modebits[1].check)))
		mode |= BIG5;
	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(modebits[2].check)))
		mode |= DIGITS;
	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(modebits[3].check)))
		mode |= LOWERCASE;
	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(modebits[4].check)))
		mode |= UPPERCASE;
	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(modebits[5].check)))
		mode |= PUNC;
	conf.keymode[6].mode = mode;

	// switch back to default recognition mode
    keus = (mode & BIG5) ? Traditional : Simplified;
	selecteer(keus);

    WTSetSpeed(conf.speed);

    gtk_widget_hide(GTK_WIDGET(preferences));	// close preferences window
    clear_draw_area(GTK_WIDGET(papier));		// redraw paper and raster
    mode = 0;
}
Example #3
0
void rfbDrawPixel(rfbScreenInfoPtr s,int x,int y,Pixel col)
{
  int rowstride = s->paddedWidthInBytes, bpp = s->bitsPerPixel>>3;
  char* colour=(char*)&col;

  if(!rfbEndianTest)
    colour += 4-bpp;
  SETPIXEL(x,y);
  rfbMarkRectAsModified(s,x,y,x+1,y+1);
}
Example #4
0
int
Graphics_DrawVLine(SDL_Surface *s, Uint16 x, Uint16 y, Uint16 l, Uint32 color)
{
    Uint8	bpp = s->format->BytesPerPixel;
    Uint8	*p = XYTOPTR(s, x, y, bpp);

    GENERIC_LOCK(s);

    while (l--) {
        SETPIXEL(p, bpp, color);
        p += s->pitch;
    }

    GENERIC_UNLOCK(s);
}
Example #5
0
void rfbDrawLine(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,Pixel col)
{
  int rowstride = s->paddedWidthInBytes, bpp = s->bitsPerPixel>>3;
  int i;
  char* colour=(char*)&col;

  if(!rfbEndianTest)
    colour += 4-bpp;

#define SWAPPOINTS { i=x1; x1=x2; x2=i; i=y1; y1=y2; y2=i; }
  if(abs(x1-x2)<abs(y1-y2)) {
    if(y1>y2)
      SWAPPOINTS
    for(i=y1;i<=y2;i++)
      SETPIXEL(x1+(i-y1)*(x2-x1)/(y2-y1),i);
    /* TODO: Maybe make this more intelligently? */
    if(x2<x1) { i=x1; x1=x2; x2=i; }
    rfbMarkRectAsModified(s,x1,y1,x2+1,y2+1);
  } else {
    if(x1>x2)
Example #6
0
int
Graphics_GradFillRect(SDL_Surface *s, SDL_Rect *rect, Uint16 max,
                      SDL_Color *top, SDL_Color *bottom, SDL_Color *last)
{
    Uint8		bpp = s->format->BytesPerPixel;
    Uint8		*p = XYTOPTR(s, rect->x, rect->y + rect->h, bpp);

    float		cr = bottom->r, cg = bottom->g, cb = bottom->b;
    float		diff_r = (float)(top->r - cr)/max;
    float		diff_g = (float)(top->g - cg)/max;
    float		diff_b = (float)(top->b - cb)/max;

    Sint8		p_diff = bpp;

    GENERIC_LOCK(s);

    for (Uint16 h = rect->h; h; h--) {
        Uint32 color = SDL_MapRGB(s->format, cr, cg, cb);

        for (Uint16 w = rect->w; w; w--, p += p_diff)
            SETPIXEL(p, bpp, color);

        cr += diff_r;
        cg += diff_g;
        cb += diff_b;

        p -= s->pitch + p_diff;
        p_diff = -p_diff;
    }

    if (last) {
        last->r = cr;
        last->g = cg;
        last->b = cb;
    }

    GENERIC_UNLOCK(s);
}
Example #7
0
static int
NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
{
	static const char module[] = "NeXTDecode";
	unsigned char *bp, *op;
	tmsize_t cc;
	uint8* row;
	tmsize_t scanline, n;

	(void) s;
	/*
	 * Each scanline is assumed to start off as all
	 * white (we assume a PhotometricInterpretation
	 * of ``min-is-black'').
	 */
	for (op = (unsigned char*) buf, cc = occ; cc-- > 0;)
		*op++ = 0xff;

	bp = (unsigned char *)tif->tif_rawcp;
	cc = tif->tif_rawcc;
	scanline = tif->tif_scanlinesize;
	if (occ % scanline)
	{
		TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read");
		return (0);
	}
	for (row = buf; cc > 0 && occ > 0; occ -= scanline, row += scanline) {
		n = *bp++;
		cc--;
		switch (n) {
		case LITERALROW:
			/*
			 * The entire scanline is given as literal values.
			 */
			if (cc < scanline)
				goto bad;
			_TIFFmemcpy(row, bp, scanline);
			bp += scanline;
			cc -= scanline;
			break;
		case LITERALSPAN: {
			tmsize_t off;
			/*
			 * The scanline has a literal span that begins at some
			 * offset.
			 */
			if( cc < 4 )
				goto bad;
			off = (bp[0] * 256) + bp[1];
			n = (bp[2] * 256) + bp[3];
			if (cc < 4+n || off+n > scanline)
				goto bad;
			_TIFFmemcpy(row+off, bp+4, n);
			bp += 4+n;
			cc -= 4+n;
			break;
		}
		default: {
			uint32 npixels = 0, grey;
			tmsize_t op_offset = 0;
			uint32 imagewidth = tif->tif_dir.td_imagewidth;
            if( isTiled(tif) )
                imagewidth = tif->tif_dir.td_tilewidth;

			/*
			 * The scanline is composed of a sequence of constant
			 * color ``runs''.  We shift into ``run mode'' and
			 * interpret bytes as codes of the form
			 * <color><npixels> until we've filled the scanline.
			 */
			op = row;
			for (;;) {
				grey = (uint32)((n>>6) & 0x3);
				n &= 0x3f;
				/*
				 * Ensure the run does not exceed the scanline
				 * bounds, potentially resulting in a security
				 * issue.
				 */
				while (n-- > 0 && npixels < imagewidth && op_offset < scanline)
					SETPIXEL(op, grey);
				if (npixels >= imagewidth)
					break;
                if (op_offset >= scanline ) {
                    TIFFErrorExt(tif->tif_clientdata, module, "Invalid data for scanline %ld",
                        (long) tif->tif_row);
                    return (0);
                }
				if (cc == 0)
					goto bad;
				n = *bp++;
				cc--;
			}
			break;
		}
		}
	}
	tif->tif_rawcp = (uint8*) bp;
	tif->tif_rawcc = cc;
	return (1);
bad:
	TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %ld",
	    (long) tif->tif_row);
	return (0);
}