< prev index next >

## src/java.desktop/unix/native/libawt_xawt/awt/multiVis.c

Print this page

     383      *  - robi.khan@eng 9/22/1999
     384      */
     385     free(colors);
     386 }
     387
     388 static XImage *
     389 ReadRegionsInList(disp,fakeVis,depth,format,width,height,bbox,regions)
     390 Display *disp ;
     391 Visual *fakeVis ;
     392 int32_t depth , width , height ;
     393 int32_t format ;
     394 XRectangle      bbox;           /* bounding box of grabbed area */
     395 list_ptr regions;/* list of regions to read from */
     396 {
     397     image_region_type   *reg;
     398     int32_t                     dst_x, dst_y;   /* where in pixmap to write (UL) */
     399     int32_t                     diff;
     400
     401     XImage              *reg_image,*ximage ;
     402     int32_t             srcRect_x,srcRect_y,srcRect_width,srcRect_height ;
     403     int32_t     rem ;
     404     int32_t     bytes_per_line;
     405     int32_t     bitmap_unit;
     406
     407     bitmap_unit = sizeof (long);
     408     if (format == ZPixmap)
     409        bytes_per_line = width*depth/8;
     410     else
     411        bytes_per_line = width/8;
     412
     413
     414     /* Find out how many more bytes are required for padding so that
     415     ** bytes per scan line will be multiples of bitmap_unit bits */
     416     if (format == ZPixmap) {
     417        rem = (bytes_per_line*8)%bitmap_unit;
     418     if (rem)
     419        bytes_per_line += (rem/8 + 1);
     420     }
     421
     422     ximage = XCreateImage(disp,fakeVis,(uint32_t) depth,format,0,NULL,
     423                           (uint32_t)width,(uint32_t)height,8,0);
     424
     425     bytes_per_line = ximage->bytes_per_line;
     426
     427     if (format == ZPixmap)
     428           ximage->data = malloc(height*bytes_per_line);
     429     else
     430         ximage->data = malloc(height*bytes_per_line*depth);
     431
     432     ximage->bits_per_pixel = depth; /** Valid only if format is ZPixmap ***/
     433
     434     for (reg = (image_region_type *) first_in_list( regions); reg;
     435          reg = (image_region_type *) next_in_list( regions))
     436     {
     437                 int32_t rect;
     438                 struct my_XRegion *vis_reg;
     439                 vis_reg = (struct my_XRegion *)(reg->visible_region);
     440                 for (rect = 0;
     441                      rect < vis_reg->numRects;
     442                      rect++)
     443                 {
     444                 /** ------------------------------------------------------------------------
     445                         Intersect bbox with visible part of region giving src rect & output
     446                         location.  Width is the min right side minus the max left side.
     447                         Similar for height.  Offset src rect so x,y are relative to
     448                         origin of win, not the root-relative visible rect of win.
     449                     ------------------------------------------------------------------------ **/
     450                     srcRect_width  = MIN( vis_reg->rects[rect].x2, bbox.width + bbox.x)
     451              - MAX( vis_reg->rects[rect].x1, bbox.x);
     452
     453                     srcRect_height = MIN( vis_reg->rects[rect].y2, bbox.height + bbox.y)
     454              - MAX( vis_reg->rects[rect].y1, bbox.y);
     455
     456                     diff = bbox.x - vis_reg->rects[rect].x1;
     457                     srcRect_x = MAX( 0, diff)  + (vis_reg->rects[rect].x1 - reg->x_rootrel - reg->border);
     458                     dst_x     = MAX( 0, -diff) ;
     459                     diff = bbox.y - vis_reg->rects[rect].y1;
     460                     srcRect_y = MAX( 0, diff)  + (vis_reg->rects[rect].y1 - reg->y_rootrel - reg->border);
     461                     dst_y     = MAX( 0, -diff) ;
     462             reg_image = XGetImage(disp,reg->win,srcRect_x,srcRect_y,
     463              (uint32_t) srcRect_width, (uint32_t) srcRect_height,AllPlanes,format) ;

     464                     TransferImage(disp,reg_image,srcRect_width,
     465                                  srcRect_height,reg,ximage,dst_x,dst_y) ;
     466             XDestroyImage(reg_image);

     467             }
     468     }
     469     return ximage ;
     470 }
     471
     472
     473 /** ------------------------------------------------------------------------
     474     ------------------------------------------------------------------------ **/
     475
     476 XImage *ReadAreaToImage(disp, srcRootWinid, x, y, width, height,
     477     numVisuals,pVisuals,numOverlayVisuals,pOverlayVisuals,numImageVisuals,
     478     pImageVisuals,vis_regions,vis_image_regions,format,allImage)
     479     Display             *disp;
     480     Window              srcRootWinid;   /* root win on which grab was done */
     481     int32_t                     x;   /* root rel UL corner of bounding box of grab */
     482     int32_t                     y;
     483     uint32_t            width;  /* size of bounding box of grab */
     484     uint32_t            height;
     485     /** int32_t                 transparentOverlays; ***/
     486     int32_t                     numVisuals;
     383      *  - robi.khan@eng 9/22/1999
     384      */
     385     free(colors);
     386 }
     387
     388 static XImage *
     389 ReadRegionsInList(disp,fakeVis,depth,format,width,height,bbox,regions)
     390 Display *disp ;
     391 Visual *fakeVis ;
     392 int32_t depth , width , height ;
     393 int32_t format ;
     394 XRectangle      bbox;           /* bounding box of grabbed area */
     395 list_ptr regions;/* list of regions to read from */
     396 {
     397     image_region_type   *reg;
     398     int32_t                     dst_x, dst_y;   /* where in pixmap to write (UL) */
     399     int32_t                     diff;
     400
     401     XImage              *reg_image,*ximage ;
     402     int32_t             srcRect_x,srcRect_y,srcRect_width,srcRect_height ;

     403
     404     ximage = XCreateImage(disp,fakeVis,(uint32_t) depth,format,0,NULL,
     405                           (uint32_t)width,(uint32_t)height,8,0);
     406
     407     ximage->data = calloc(height*ximage->bytes_per_line*((format == ZPixmap) ? 1 : depth),
     408                          sizeof(char));

     409
     410     ximage->bits_per_pixel = depth; /** Valid only if format is ZPixmap ***/
     411
     412     for (reg = (image_region_type *) first_in_list( regions); reg;
     413          reg = (image_region_type *) next_in_list( regions))
     414     {
     415                 int32_t rect;
     416                 struct my_XRegion *vis_reg;
     417                 vis_reg = (struct my_XRegion *)(reg->visible_region);
     418                 for (rect = 0;
     419                      rect < vis_reg->numRects;
     420                      rect++)
     421                 {
     422                 /** ------------------------------------------------------------------------
     423                         Intersect bbox with visible part of region giving src rect & output
     424                         location.  Width is the min right side minus the max left side.
     425                         Similar for height.  Offset src rect so x,y are relative to
     426                         origin of win, not the root-relative visible rect of win.
     427                     ------------------------------------------------------------------------ **/
     428                     srcRect_width  = MIN( vis_reg->rects[rect].x2, bbox.width + bbox.x)
     429              - MAX( vis_reg->rects[rect].x1, bbox.x);
     430
     431                     srcRect_height = MIN( vis_reg->rects[rect].y2, bbox.height + bbox.y)
     432              - MAX( vis_reg->rects[rect].y1, bbox.y);
     433
     434                     diff = bbox.x - vis_reg->rects[rect].x1;
     435                     srcRect_x = MAX( 0, diff)  + (vis_reg->rects[rect].x1 - reg->x_rootrel - reg->border);
     436                     dst_x     = MAX( 0, -diff) ;
     437                     diff = bbox.y - vis_reg->rects[rect].y1;
     438                     srcRect_y = MAX( 0, diff)  + (vis_reg->rects[rect].y1 - reg->y_rootrel - reg->border);
     439                     dst_y     = MAX( 0, -diff) ;
     440             reg_image = XGetImage(disp,reg->win,srcRect_x,srcRect_y,
     441              (uint32_t) srcRect_width, (uint32_t) srcRect_height,AllPlanes,format) ;
     442              if(reg_image)
     443              {
     444                 TransferImage(disp,reg_image,srcRect_width,
     445                               srcRect_height,reg,ximage,dst_x,dst_y) ;
     446                 XDestroyImage(reg_image);
     447
     448              }
     449             }
     450     }
     451     return ximage ;
     452 }
     453
     454
     455 /** ------------------------------------------------------------------------
     456     ------------------------------------------------------------------------ **/
     457
     458 XImage *ReadAreaToImage(disp, srcRootWinid, x, y, width, height,
     459     numVisuals,pVisuals,numOverlayVisuals,pOverlayVisuals,numImageVisuals,
     460     pImageVisuals,vis_regions,vis_image_regions,format,allImage)
     461     Display             *disp;
     462     Window              srcRootWinid;   /* root win on which grab was done */
     463     int32_t                     x;   /* root rel UL corner of bounding box of grab */
     464     int32_t                     y;
     465     uint32_t            width;  /* size of bounding box of grab */
     466     uint32_t            height;
     467     /** int32_t                 transparentOverlays; ***/
     468     int32_t                     numVisuals;

< prev index next >