@@ -1253,21 +1253,8 @@ fix_total_crop(Gif_Stream *dest, Gif_Image *srci, int merger_index)
1253
1253
1254
1254
1255
1255
static void
1256
- handle_screen ( Gif_Stream * dest , uint16_t width , uint16_t height )
1256
+ handle_flip_and_rotate ( Gif_Image * desti , Gt_Frame * fr )
1257
1257
{
1258
- /* Set the screen width & height, if the current input width and height are
1259
- larger */
1260
- if (dest -> screen_width < width )
1261
- dest -> screen_width = width ;
1262
- if (dest -> screen_height < height )
1263
- dest -> screen_height = height ;
1264
- }
1265
-
1266
- static void
1267
- handle_flip_and_screen (Gif_Stream * dest , Gif_Image * desti , Gt_Frame * fr )
1268
- {
1269
- Gif_Stream * gfs = fr -> stream ;
1270
-
1271
1258
desti -> left += fr -> left_offset ;
1272
1259
desti -> top += fr -> top_offset ;
1273
1260
@@ -1286,12 +1273,6 @@ handle_flip_and_screen(Gif_Stream* dest, Gif_Image* desti, Gt_Frame* fr)
1286
1273
1287
1274
desti -> left -= fr -> left_offset ;
1288
1275
desti -> top -= fr -> top_offset ;
1289
-
1290
- /* handle screen size, which might have height & width exchanged */
1291
- if (fr -> rotation == 1 || fr -> rotation == 3 )
1292
- handle_screen (dest , gfs -> screen_height , gfs -> screen_width );
1293
- else
1294
- handle_screen (dest , gfs -> screen_width , gfs -> screen_height );
1295
1276
}
1296
1277
1297
1278
static void
@@ -1611,11 +1592,10 @@ merge_frame_interval(Gt_Frameset *fset, int f1, int f2,
1611
1592
1612
1593
srci -> transparent = old_transp ; /* restore real transparent value */
1613
1594
1614
- /* Flipping and rotating, and also setting the screen size */
1615
- if (fr -> flip_horizontal || fr -> flip_vertical || fr -> rotation )
1616
- handle_flip_and_screen (dest , desti , fr );
1617
- else
1618
- handle_screen (dest , fr -> stream -> screen_width , fr -> stream -> screen_height );
1595
+ /* Flipping and rotating */
1596
+ if (fr -> flip_horizontal || fr -> flip_vertical || fr -> rotation ) {
1597
+ handle_flip_and_rotate (desti , fr );
1598
+ }
1619
1599
1620
1600
/* Names and comments */
1621
1601
if (fr -> name || fr -> no_name ) {
@@ -1663,6 +1643,37 @@ merge_frame_interval(Gt_Frameset *fset, int f1, int f2,
1663
1643
desti -> disposal = fr -> disposal ;
1664
1644
}
1665
1645
1646
+ /* logical screen */
1647
+ if (output_data -> screen_mode <= 0 ) {
1648
+ int w , h ;
1649
+ if (output_data -> screen_mode < 0
1650
+ || fr -> crop
1651
+ || ((fr -> left >= 0 || fr -> top >= 0 ) && !fr -> position_is_offset )) {
1652
+ w = desti -> left + desti -> width ;
1653
+ h = desti -> top + desti -> height ;
1654
+ } else {
1655
+ if (fr -> rotation == 1 || fr -> rotation == 3 ) {
1656
+ w = fr -> stream -> screen_height ;
1657
+ h = fr -> stream -> screen_width ;
1658
+ } else {
1659
+ w = fr -> stream -> screen_width ;
1660
+ h = fr -> stream -> screen_height ;
1661
+ }
1662
+ if (fr -> left >= 0 ) {
1663
+ w += fr -> left ;
1664
+ }
1665
+ if (fr -> top >= 0 ) {
1666
+ h += fr -> top ;
1667
+ }
1668
+ }
1669
+ if (w > dest -> screen_width ) {
1670
+ dest -> screen_width = w ;
1671
+ }
1672
+ if (h > dest -> screen_height ) {
1673
+ dest -> screen_height = h ;
1674
+ }
1675
+ }
1676
+
1666
1677
/* compress immediately if possible to save on memory */
1667
1678
if (desti -> img ) {
1668
1679
if (compress_immediately > 0 ) {
@@ -1710,28 +1721,10 @@ merge_frame_interval(Gt_Frameset *fset, int f1, int f2,
1710
1721
}
1711
1722
/** END MERGE LOOP **/
1712
1723
1713
- /* Cropping the whole output? Reset logical screen */
1714
- if (merger [0 ]-> crop && merger [0 ]-> crop == merger [nmerger - 1 ]-> crop ) {
1715
- /* 13.May.2008: Set the logical screen to the cropped dimensions */
1716
- /* 18.May.2008: Unless --crop-transparency is on */
1717
- Gt_Crop * crop = merger [0 ]-> crop ;
1718
- if (crop -> transparent_edges )
1719
- dest -> screen_width = dest -> screen_height = 0 ;
1720
- else if (merger [0 ]-> rotation == 1 || merger [0 ]-> rotation == 3 ) {
1721
- dest -> screen_width = (crop -> h > 0 ? crop -> h : 0 );
1722
- dest -> screen_height = (crop -> w > 0 ? crop -> w : 0 );
1723
- } else {
1724
- dest -> screen_width = (crop -> w > 0 ? crop -> w : 0 );
1725
- dest -> screen_height = (crop -> h > 0 ? crop -> h : 0 );
1726
- }
1727
- }
1728
-
1729
- /* Set the logical screen from the user's preferences */
1730
- if (output_data -> screen_width >= 0 )
1724
+ if (output_data -> screen_mode == 1 ) {
1731
1725
dest -> screen_width = output_data -> screen_width ;
1732
- if (output_data -> screen_height >= 0 )
1733
1726
dest -> screen_height = output_data -> screen_height ;
1734
- Gif_CalculateScreenSize ( dest , 0 );
1727
+ }
1735
1728
1736
1729
/* Find the background color in the colormap, or add it if we can */
1737
1730
set_background (dest , output_data );
0 commit comments