< prev index next >

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

Print this page

    @@ -398,38 +398,16 @@
         int32_t                     dst_x, dst_y;   /* where in pixmap to write (UL) */
         int32_t                     diff;

         XImage              *reg_image,*ximage ;
         int32_t             srcRect_x,srcRect_y,srcRect_width,srcRect_height ;
    -    int32_t     rem ;
    -    int32_t     bytes_per_line;
    -    int32_t     bitmap_unit;
    -
    -    bitmap_unit = sizeof (long);
    -    if (format == ZPixmap)
    -       bytes_per_line = width*depth/8;
    -    else
    -       bytes_per_line = width/8;
    -
    -
    -    /* Find out how many more bytes are required for padding so that
    -    ** bytes per scan line will be multiples of bitmap_unit bits */
    -    if (format == ZPixmap) {
    -       rem = (bytes_per_line*8)%bitmap_unit;
    -    if (rem)
    -       bytes_per_line += (rem/8 + 1);
    -    }

         ximage = XCreateImage(disp,fakeVis,(uint32_t) depth,format,0,NULL,
                               (uint32_t)width,(uint32_t)height,8,0);

    -    bytes_per_line = ximage->bytes_per_line;
    -
    -    if (format == ZPixmap)
    -          ximage->data = malloc(height*bytes_per_line);
    -    else
    -        ximage->data = malloc(height*bytes_per_line*depth);
    +    ximage->data = calloc(height*ximage->bytes_per_line*((format == ZPixmap) ? 1 : depth),
    +                         sizeof(char));

         ximage->bits_per_pixel = depth; /** Valid only if format is ZPixmap ***/

         for (reg = (image_region_type *) first_in_list( regions); reg;
              reg = (image_region_type *) next_in_list( regions))

    @@ -459,13 +437,17 @@
                         diff = bbox.y - vis_reg->rects[rect].y1;
                         srcRect_y = MAX( 0, diff)  + (vis_reg->rects[rect].y1 - reg->y_rootrel - reg->border);
                         dst_y     = MAX( 0, -diff) ;
                 reg_image = XGetImage(disp,reg->win,srcRect_x,srcRect_y,
                  (uint32_t) srcRect_width, (uint32_t) srcRect_height,AllPlanes,format) ;
    +             if(reg_image)
    +             {
                         TransferImage(disp,reg_image,srcRect_width,
                                      srcRect_height,reg,ximage,dst_x,dst_y) ;
                 XDestroyImage(reg_image);
    +
    +             }
                 }
         }
         return ximage ;
     }

< prev index next >