[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    Re: CreateDIBSection() patch
From:       Kristian Nielsen <kristian.nielsen () risoe ! dk>
Date:       1999-08-24 7:55:44
[Download RAW message or body]

First, my appologies; I somehow managed to send in the wrong patch in my
previous mail to wine-patches, which wouldn't even compile! But now we
should better finish the discussion before I send in the corrected patch.

> Date: Fri, 20 Aug 1999 18:10:01 +0200
> From: Eric Pouech <Eric.Pouech@wanadoo.fr>

> just a question: altering the sign of bmHeight in DIB creation will
> change the Y axis orientation of the bitmap which I doubt will be
> compatible with all apps i'd rather leave X11DRV_DIB_CreateDIBSection
> untouched, but change the sign of bmHeight in bitmap.c
> (BITMAP_GetObject for DIBSECTIONs) (which is anyway what the KB
> article says)

Ok, I tried this, and it also fixes the problem in the "Magic the
Gathering" demo. Here is the small patch:

----------------------------------------------------------------------
--- ./objects/bitmap.c  1999/08/24 05:14:18     1.1
+++ ./objects/bitmap.c  1999/08/24 05:21:52
@@ -719,6 +719,14 @@
        }
 
        memcpy( buffer, bmp->dib, count );
+       if(count >= sizeof(BITMAP) &&
+          ((DIBSECTION *)buffer)->dsBm.bmHeight < 0)
+         ((DIBSECTION *)buffer)->dsBm.bmHeight =
+           -((DIBSECTION *)buffer)->dsBm.bmHeight;
+       if(count >= sizeof(DIBSECTION) &&
+          ((DIBSECTION *)buffer)->dsBmih.biHeight < 0)
+         ((DIBSECTION *)buffer)->dsBmih.biHeight =
+           -((DIBSECTION *)buffer)->dsBmih.biHeight;
        return count;
     }
     else
----------------------------------------------------------------------

Note that the sign in the returned BITMAP must be changed for the
program to work, not just in the BITMAPINFOHEADER as per the
knowledgebase article.

Hm, can we get a definite ruling as to which approach is the correct one
(changing the sign once at creation, or every time in the GetObject())?
I wonder if applications will even be able to tell the difference (the
knowledge base article seems to imply that they cannot), are there any
other ways than GetObject() to see the internal structure of a DIB?

Anyway, if people are happy with this new patch I will submit it to
wine-patches.

 - Kristian.

> Kristian Nielsen wrote:
> > 
> > This patch fixes a bug in CreateDIBSection() when called with a negative
> > height. In this case, the created DIB must NOT have a negative
> > height. Microsoft knowledgebase article #Q186586 says on the subject:
> > 
> > ----------------------------------------------------------------------
> > PRB: GetObject() Always Returns Positive Height For DIB Sections
> > 
> > SYMPTOMS
> > 
> > When you use GetObject() to obtain information about a DIB section,
> > GetObject() always returns a DIBSECTION containing a BITMAPINFOHEADER
> > with a positive height value, regardless of the sign of the height it
> > was created with. If you need to track the sign of the height in an
> > application, you will need to do this programmatically.
> > ----------------------------------------------------------------------


=========================================================================

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic