Fix oleaut32/olepicture (2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This one fixes the formulas for the scanlines.

This patch fixes the loading of jpeg images through OleLoadPicture

According to MSDN, each scanline of a DIB has to be aligned on DWORD.
Moreover BITMAPINFOHEADER says that colors should be BGR.

These changes fix the SplashScreen of emule. Now it looks as it should.

a+ 

Max

ChangeLog:
  * Fixes scanline size in OLEPictureImpl_Load for jpeg
  * Convert from RGB to BGR according to BITMAPINFOHEADER MSDN
documentation.

-- 
Maxime Bellengà <maxime.bellenge@laposte.net>
Index: wine/dlls/oleaut32/olepicture.c
===================================================================
RCS file: /home/wine/wine/dlls/oleaut32/olepicture.c,v
retrieving revision 1.24
diff -u -r1.24 olepicture.c
--- wine/dlls/oleaut32/olepicture.c	9 Jan 2003 06:04:33 -0000	1.24
+++ wine/dlls/oleaut32/olepicture.c	30 Apr 2003 10:30:47 -0000
@@ -5,6 +5,7 @@
  *
  * Copyright 2000 Huw D M Davies for CodeWeavers.
  * Copyright 2001 Marcus Meissner
+ * Copyright 2003 Maxime Bellengé
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -990,11 +991,14 @@
     struct jpeg_error_mgr		jerr;
     int					ret;
     JDIMENSION				x;
-    JSAMPROW				samprow;
+    JSAMPROW				samprow,oldsamprow;
     BITMAPINFOHEADER			bmi;
     LPBYTE				bits;
     HDC					hdcref;
     struct jpeg_source_mgr		xjsm;
+    LPBYTE                              oldbits;
+    int                                 padding;
+    int i;
 
     /* This is basically so we can use in-memory data for jpeg decompression.
      * We need to have all the functions.
@@ -1011,25 +1015,44 @@
     jpeg_create_decompress(&jd);
     jd.src = &xjsm;
     ret=jpeg_read_header(&jd,TRUE);
+    jd.out_color_space = JCS_RGB;
     jpeg_start_decompress(&jd);
     if (ret != JPEG_HEADER_OK) {
 	ERR("Jpeg image in stream has bad format, read header returned %d.\n",ret);
 	HeapFree(GetProcessHeap(),0,xbuf);
 	return E_FAIL;
     }
-    bits = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(jd.output_height+1)*jd.output_width*jd.output_components);
+
+    i = jd.output_width*jd.output_components;
+    if ((i%sizeof(DWORD))>0) {
+      padding = i%sizeof(DWORD);
+      i += i%sizeof(DWORD);
+    } else {
+      padding = 0;
+    }
+    bits = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(jd.output_height+1)*i);
     samprow=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,jd.output_width*jd.output_components);
+
+    oldbits = bits;
+    oldsamprow = samprow;
     while ( jd.output_scanline<jd.output_height ) {
       x = jpeg_read_scanlines(&jd,&samprow,1);
       if (x != 1) {
 	FIXME("failed to read current scanline?\n");
 	break;
       }
-      memcpy( bits+jd.output_scanline*jd.output_width*jd.output_components,
-	      samprow,
-      	      jd.output_width*jd.output_components
-      );
+      /* We have to convert from RGB to BGR, see MSDN/ BITMAPINFOHEADER */
+      for(i=0;i<jd.output_width;i++,samprow+=jd.output_components) {
+	*(bits++) = *(samprow+2);
+	*(bits++) = *(samprow+1);
+	*(bits++) = *(samprow);
+      } 
+      memset(bits,0x00,padding);
+      bits += padding;
+      samprow = oldsamprow;
     }
+    bits = oldbits;
+
     bmi.biSize		= sizeof(bmi);
     bmi.biWidth		=  jd.output_width;
     bmi.biHeight	= -jd.output_height;

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux