Exemplo n.º 1
0
void
Do_Paste(
        int x,
        int y )
{
  XImage *color_img, *mono_img;

  if (GraphicsOp == S_PASTE) {
    color_img = CutCopy;
    mono_img  = CutCopy_mono;
   }
  else if (GraphicsOp == S_ROTATE) {
    color_img = Rotate;
    mono_img  = Rotate_mono;
   }
  else {
    color_img = Scale;
    mono_img  = Scale_mono;
   }

  if (GraphicsOp == S_PASTE)
  {
    GraphicsOp = S_WAIT_RELEASE;
  }
  else
  {
    GraphicsOp = Backup_G_Op;
    if (Backup_G_Op == SELECT)
      Start_HotBox(CONTINUE);
    Backup_G_Op = NULL;
  }

  XPutImage(dpy, color_icon, Color_gc, color_img, 0, 0, x, y,
  color_img->width, color_img->height);
  XPutImage(dpy, mono_icon, Mono_gc, mono_img, 0, 0, x, y,
  mono_img->width, mono_img->height);
  XCopyArea(dpy, color_icon, XtWindow(iconImage), Color_gc,
  x, y, color_img->width, color_img->height, x, y);
  XCopyArea(dpy, mono_icon, XtWindow(monoImage), Mono_gc,
  x, y, mono_img->width, mono_img->height, x, y);
  Transfer_Back_Image(x, y, x+color_img->width, y+color_img->height, FILL);
}
Exemplo n.º 2
0
void
Process_Cut( void )
{
  Process_Copy(&CutCopy, &CutCopy_mono);
  if (Selected) {
    Backup_Icons();
    XSetForeground(dpy, scratch_gc, Transparent);
    XFillRectangle(dpy, color_icon, scratch_gc, select_box.x, select_box.y,
 select_box.width, select_box.height);
    XFillRectangle(dpy, mono_icon, scratch_gc, select_box.x, select_box.y,
 select_box.width, select_box.height);
    XFillRectangle(dpy, XtWindow(iconImage), scratch_gc,
 select_box.x, select_box.y, select_box.width, select_box.height);
    XFillRectangle(dpy, XtWindow(monoImage), scratch_gc,
 select_box.x, select_box.y, select_box.width, select_box.height);
    Transfer_Back_Image(select_box.x, select_box.y,
   (select_box.x+select_box.width),
   (select_box.y+select_box.height), FILL);
 XtSetSensitive( editMenu_paste_pb, True);
   }
}
Exemplo n.º 3
0
int
Mirror_Image(
        int orientation )
{
  XRectangle tmp_box;
  XImage *new_image, *old_image, *new_mono, *old_mono;
  unsigned long n;
  int i, j;

#ifdef DEBUG
  if (debug)
    stat_out("Entering Mirror_Image\n");
#endif

  if (!Selected)
    return (False);
/*--- get src. & dst. images from both color and monochrome icons ---*/

  old_image = XGetImage(dpy, color_icon, select_box.x, select_box.y,
		select_box.width, select_box.height, AllPlanes, format);
  if (old_image == NULL)
    return (False);
  new_image  = XGetImage(dpy, color_icon, select_box.x, select_box.y,
		select_box.width, select_box.height, AllPlanes, format);
  if (new_image == NULL) {
    XDestroyImage(old_image);
    return (False);
   }

  old_mono = XGetImage(dpy, mono_icon, select_box.x, select_box.y,
		select_box.width, select_box.height, AllPlanes, format);
  if (old_mono == NULL) {
    XDestroyImage(old_image);
    XDestroyImage(new_image);
    return (False);
   }
  new_mono  = XGetImage(dpy, mono_icon, select_box.x, select_box.y,
		select_box.width, select_box.height, AllPlanes, format);
  if (new_mono == NULL) {
    XDestroyImage(old_image);
    XDestroyImage(new_image);
    XDestroyImage(old_mono);
    return (False);
   }

#ifdef DEBUG
  if (debug)
    stat_out("  - got the images\n");
#endif

  for (i=0; i<(int)select_box.width; i++)
    for (j=0; j<(int)select_box.height; j++) {
      if (orientation == VERTICAL) {
	n = XGetPixel(old_image, i, j);
	XPutPixel(new_image, i, (select_box.height-1)-j, n);
	n = XGetPixel(old_mono, i, j);
	XPutPixel(new_mono, i, (select_box.height-1)-j, n);
       }
      else {
	n = XGetPixel(old_image, i, j);
	XPutPixel(new_image, (select_box.width-1)-i, j, n);
	n = XGetPixel(old_mono, i, j);
	XPutPixel(new_mono, (select_box.width-1)-i, j, n);
       }
     } /* for(j...) */
  XFlush(dpy);

  XPutImage(dpy, color_icon, Color_gc, new_image, 0, 0,
		select_box.x, select_box.y,
		select_box.width, select_box.height);
  XPutImage(dpy, XtWindow(iconImage), Color_gc, new_image, 0, 0,
		select_box.x, select_box.y,
		select_box.width, select_box.height);

  XPutImage(dpy, mono_icon, Mono_gc, new_mono, 0, 0,
		select_box.x, select_box.y,
		select_box.width, select_box.height);
  XPutImage(dpy, XtWindow(monoImage), Mono_gc, new_mono, 0, 0,
		select_box.x, select_box.y,
		select_box.width, select_box.height);
  Transfer_Back_Image(select_box.x, select_box.y,
			(select_box.x+select_box.width-1),
			(select_box.y+select_box.height-1),
			FILL);

  XDestroyImage(new_image);
  XDestroyImage(old_image);
  XDestroyImage(new_mono);
  XDestroyImage(old_mono);

#ifdef DEBUG
  if (debug)
    stat_out("Leaving Mirror_Image\n");
#endif

  return (True);
}
Exemplo n.º 4
0
int
Flood_Region(
        int flood_x,
        int flood_y )
{
  XImage *ImagePix, *MonoPix;
  unsigned long new_pixel, new_mono;

#ifdef DEBUG
  int i, j;
  unsigned long old_pixel;

  if (debug)
    stat_out("Entering Flood_Region\n");
#endif

/*--- get the image from the (adjusted) box ---*/

  ImagePix = XGetImage(dpy, color_icon, 0, 0, icon_width, icon_height,
		AllPlanes, format);
  if (ImagePix == NULL)
    return (False);
  MonoPix = XGetImage(dpy, mono_icon, 0, 0, icon_width, icon_height,
		AllPlanes, format);
  if (MonoPix == NULL)
    return (False);

#ifdef DEBUG
  if (debug)
    stat_out("  - got the image\n");
#endif

  if (ColorBlock == STATIC_COLOR) {
    new_pixel = StaticPen[CurrentColor];
    new_mono  = StaticMono[CurrentColor];
   }
  else {
    new_pixel = DynamicPen[CurrentColor];
    new_mono  = DynamicMono[CurrentColor];
   }

#ifdef DEBUG
  if (debug) {
    for (i=0; i<icon_width; i++)
      for (j=0; j<icon_height; j++) {
	old_pixel = XGetPixel(ImagePix, i, j);
	if ((old_pixel < 0) || (old_pixel > 255))
	  stat_out("      BAD PIXEL VALUE (%d) AT [%d,%d]\n", old_pixel, i, j);
       }
    stat_out("  SUCCESSFULLY accessed each pixel in the image\n");
   }
#endif

  flood_min_x = icon_width;
  flood_min_y = icon_height;
  flood_max_x = 0;
  flood_max_y = 0;

  Flood_Fill(ImagePix, MonoPix, flood_x, flood_y, ImagePix->width,
	ImagePix->height, new_pixel, new_mono);
  XFlush(dpy);

  Backup_Icons();
  XPutImage(dpy, color_icon, Color_gc, ImagePix, 0, 0, 0, 0,
		icon_width, icon_height);
  XPutImage(dpy, XtWindow(iconImage), Color_gc, ImagePix,
		0, 0, 0, 0, icon_width, icon_height);
  XPutImage(dpy, mono_icon, Mono_gc, MonoPix, 0, 0, 0, 0,
		icon_width, icon_height);
  XPutImage(dpy, XtWindow(monoImage), Mono_gc, MonoPix,
		0, 0, 0, 0, icon_width, icon_height);
  Transfer_Back_Image(flood_min_x, flood_min_y,
			flood_max_x, flood_max_y, FILL);
  XDestroyImage(ImagePix);
  XDestroyImage(MonoPix);

#ifdef DEBUG
  if (debug)
    stat_out("Leaving Flood_Region\n");
#endif

  return (True);

}