< prev index next >

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

Print this page




 377          }
 378        }
 379        break;
 380     }
 381 
 382     /* Fix memory leak by freeing colors
 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     XImage              *ximage ;



 398 
 399     ximage = XCreateImage(disp,fakeVis,(uint32_t) depth,format,0,NULL,
 400                           (uint32_t)width,(uint32_t)height,8,0);
 401 
 402     ximage->data = calloc(ximage->bytes_per_line*height*((format==ZPixmap)? 1 : depth), sizeof(char));
 403     ximage->bits_per_pixel = depth; /** Valid only if format is ZPixmap ***/
 404 
 405     for (image_region_type* reg = (image_region_type *) first_in_list( regions); reg;
 406          reg = (image_region_type *) next_in_list( regions))
 407     {

 408                 struct my_XRegion *vis_reg = (struct my_XRegion *)(reg->visible_region);
 409                 for (int32_t rect = 0; rect < vis_reg->numRects; rect++)
 410                 {
 411                     /** ------------------------------------------------------------------------
 412                             Intersect bbox with visible part of region giving src rect & output
 413                             location.  Width is the min right side minus the max left side.
 414                             Similar for height.  Offset src rect so x,y are relative to
 415                             origin of win, not the root-relative visible rect of win.
 416                         ------------------------------------------------------------------------ **/
 417                         int32_t srcRect_width  = MIN( vis_reg->rects[rect].x2, bbox.width + bbox.x)
 418                                          - MAX( vis_reg->rects[rect].x1, bbox.x);
 419 
 420                         int32_t srcRect_height = MIN( vis_reg->rects[rect].y2, bbox.height + bbox.y)
 421                                          - MAX( vis_reg->rects[rect].y1, bbox.y);
 422 
 423                         int32_t diff = bbox.x - vis_reg->rects[rect].x1;
 424                         int32_t srcRect_x = MAX( 0, diff)  + (vis_reg->rects[rect].x1 - reg->x_rootrel - reg->border);
 425                         int32_t dst_x     = MAX( 0, -diff) ;
 426 
 427                         diff = bbox.y - vis_reg->rects[rect].y1;
 428                         int32_t srcRect_y = MAX( 0, diff)  + (vis_reg->rects[rect].y1 - reg->y_rootrel - reg->border);
 429                         int32_t dst_y     = MAX( 0, -diff) ;
 430                         XImage* reg_image = XGetImage(disp,reg->win,srcRect_x,srcRect_y,
 431                                             (uint32_t) srcRect_width, (uint32_t) srcRect_height,AllPlanes,format) ;
 432 
 433                         if (reg_image) {
 434                             TransferImage(disp,reg_image,srcRect_width,
 435                                             srcRect_height,reg,ximage,dst_x,dst_y) ;
 436                             XDestroyImage(reg_image);
 437                         }
 438                 }
 439     }
 440     return ximage ;
 441 }
 442 
 443 
 444 /** ------------------------------------------------------------------------
 445     ------------------------------------------------------------------------ **/
 446 
 447 XImage *ReadAreaToImage(disp, srcRootWinid, x, y, width, height,
 448     numVisuals,pVisuals,numOverlayVisuals,pOverlayVisuals,numImageVisuals,
 449     pImageVisuals,vis_regions,vis_image_regions,format,allImage)
 450     Display             *disp;




 377          }
 378        }
 379        break;
 380     }
 381 
 382     /* Fix memory leak by freeing colors
 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     XImage              *reg_image, *ximage ;
 398     int32_t             srcRect_x,srcRect_y,srcRect_width,srcRect_height ;
 399     int32_t             dst_x, dst_y;   /* where in pixmap to write (UL) */
 400     int32_t             diff;
 401 
 402     ximage = XCreateImage(disp,fakeVis,(uint32_t) depth,format,0,NULL,
 403                           (uint32_t)width,(uint32_t)height,8,0);
 404 
 405     ximage->data = calloc(ximage->bytes_per_line*height*((format==ZPixmap)? 1 : depth), sizeof(char));
 406     ximage->bits_per_pixel = depth; /** Valid only if format is ZPixmap ***/
 407 
 408     for (reg = (image_region_type *) first_in_list( regions); reg;
 409          reg = (image_region_type *) next_in_list( regions))
 410     {
 411                 int32_t rect;
 412                 struct my_XRegion *vis_reg = (struct my_XRegion *)(reg->visible_region);
 413                 for (rect = 0; rect < vis_reg->numRects; rect++)
 414                 {
 415                     /** ------------------------------------------------------------------------
 416                             Intersect bbox with visible part of region giving src rect & output
 417                             location.  Width is the min right side minus the max left side.
 418                             Similar for height.  Offset src rect so x,y are relative to
 419                             origin of win, not the root-relative visible rect of win.
 420                         ------------------------------------------------------------------------ **/
 421                         srcRect_width  = MIN( vis_reg->rects[rect].x2, bbox.width + bbox.x)
 422                                          - MAX( vis_reg->rects[rect].x1, bbox.x);
 423 
 424                         srcRect_height = MIN( vis_reg->rects[rect].y2, bbox.height + bbox.y)
 425                                          - MAX( vis_reg->rects[rect].y1, bbox.y);
 426 
 427                         diff = bbox.x - vis_reg->rects[rect].x1;
 428                         srcRect_x = MAX( 0, diff)  + (vis_reg->rects[rect].x1 - reg->x_rootrel - reg->border);
 429                         dst_x     = MAX( 0, -diff) ;
 430 
 431                         diff = bbox.y - vis_reg->rects[rect].y1;
 432                         srcRect_y = MAX( 0, diff)  + (vis_reg->rects[rect].y1 - reg->y_rootrel - reg->border);
 433                         dst_y     = MAX( 0, -diff) ;
 434                         reg_image = XGetImage(disp,reg->win,srcRect_x,srcRect_y,
 435                                             (uint32_t) srcRect_width, (uint32_t) srcRect_height,AllPlanes,format) ;
 436 
 437                         if (reg_image) {
 438                             TransferImage(disp,reg_image,srcRect_width,
 439                                             srcRect_height,reg,ximage,dst_x,dst_y) ;
 440                             XDestroyImage(reg_image);
 441                         }
 442                 }
 443     }
 444     return ximage ;
 445 }
 446 
 447 
 448 /** ------------------------------------------------------------------------
 449     ------------------------------------------------------------------------ **/
 450 
 451 XImage *ReadAreaToImage(disp, srcRootWinid, x, y, width, height,
 452     numVisuals,pVisuals,numOverlayVisuals,pOverlayVisuals,numImageVisuals,
 453     pImageVisuals,vis_regions,vis_image_regions,format,allImage)
 454     Display             *disp;


< prev index next >