update dev300-m58
[ooovba.git] / applied_patches / 0113-unxsplash-bmp-alias.diff
blob3aa48267e0203788a81806c7737feedd532f49b8
1 diff --git desktop/unx/source/splashx.c desktop/unx/source/splashx.c
2 index b3b6da0..c792cc0 100644
3 --- desktop/unx/source/splashx.c
4 +++ desktop/unx/source/splashx.c
5 @@ -65,6 +65,7 @@ static Visual *visual = NULL;
7 static int width = WINDOW_WIDTH;
8 static int height = WINDOW_HEIGHT;
9 +static int alias = 0;
11 static Colormap color_map;
12 static Window win;
13 @@ -83,7 +84,7 @@ static color_t framecol = { 0xD3, 0xD3, 0xD3 };
14 static XColor barcolor;
15 static XColor framecolor;
17 -static color_t *bitmap = NULL;
18 +static char *bitmap = NULL;
20 #define BMP_HEADER_LEN 14
21 #define WIN_INFO_LEN 40
22 @@ -120,7 +121,7 @@ int splash_load_bmp( char *filename )
23 if ( read( fd, file_header, BMP_HEADER_LEN ) != BMP_HEADER_LEN || file_header[0] != 'B' || file_header[1] != 'M' )
24 LOAD_FAILURE( "Not a bitmap.\n" );
26 - int file_size = UINT32( file_header + 2 );
27 + //int file_size = UINT32( file_header + 2 );
29 char info_header[ WIN_INFO_LEN ];
30 if ( read( fd, info_header, 4 ) != 4 )
31 @@ -135,6 +136,7 @@ int splash_load_bmp( char *filename )
33 width = UINT32( info_header + 4 );
34 height = UINT32( info_header + 8 );
35 + alias = width % 4;
37 int bits = UINT16( info_header + 14 );
38 int compression = UINT16( info_header + 16 );
39 @@ -145,7 +147,7 @@ int splash_load_bmp( char *filename )
40 if ( compression != 0 )
41 LOAD_FAILURE( "Just uncompressed bitmaps are supported.\n" );
43 - size_t bitmap_size = width * height * 3;
44 + ssize_t bitmap_size = width * height * 3 + alias * height;
45 bitmap = malloc( bitmap_size );
46 if ( bitmap == NULL )
47 LOAD_FAILURE( "Cannot allocate memory for the data.\n" );
48 @@ -280,6 +282,7 @@ static void create_pixmap()
49 for ( y = 0; y < height; ++y ) \
50 { \
51 unsigned long red_delta = 0, green_delta = 0, blue_delta = 0; \
52 + color_t *in = (color_t *)( bitmap + y * ( width * 3 + alias ) ); \
53 for ( x = 0; x < width; ++x, ++in ) \
54 { \
55 unsigned long red = in->r + red_delta; \
56 @@ -304,7 +307,6 @@ static void create_pixmap()
57 } \
60 - color_t *in = bitmap;
61 char *out = data;
63 if ( bpp == 32 )
64 @@ -371,7 +373,7 @@ static void create_pixmap()
65 int x, y;
66 for ( y = 0; y < height; ++y )
68 - color_t *color = bitmap + y * width;
69 + color_t *color = (color_t *)( bitmap + y * ( width * 3 + alias ) );
71 int delta = 0;
72 for ( x = 0; x < width; ++x, ++color )