Changeset 4598 for trunk/src


Ignore:
Timestamp:
Nov 15, 2000, 5:10:41 PM (25 years ago)
Author:
sandervl
Message:

SetDIBits bugfix (WORD vs DWORD aligned scanlines)

Location:
trunk/src/gdi32
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gdi32/dibitmap.cpp

    r4590 r4598  
    1 /* $Id: dibitmap.cpp,v 1.12 2000-11-14 14:28:22 sandervl Exp $ */
     1/* $Id: dibitmap.cpp,v 1.13 2000-11-15 16:10:40 sandervl Exp $ */
    22
    33/*
     
    314314    //SvL: Open32's SetDIBits really messes things up for 1 bpp bitmaps, must use SetBitmapBits
    315315    if(pBitmapInfo->bmiHeader.biBitCount == 1 && startscan == 0 && numlines == pBitmapInfo->bmiHeader.biHeight)
    316     {
    317         int   linewidth = DIB_GetDIBWidthBytes(pBitmapInfo->bmiHeader.biWidth, 1);
    318         char *newpix    = (char *)malloc(linewidth*pBitmapInfo->bmiHeader.biHeight);
     316    {//WARNING: hack alert!
     317        int   dibwidth  = DIB_GetDIBWidthBytes(pBitmapInfo->bmiHeader.biWidth, 1);
     318        int   bmpwidth  = BITMAP_GetWidthBytes(pBitmapInfo->bmiHeader.biWidth, 1);
     319        char *newpix    = (char *)malloc(dibwidth*pBitmapInfo->bmiHeader.biHeight);
    319320        char *orgpix    = (char *)pBits;
    320321        int   ret;
    321322
    322         newpix += ((pBitmapInfo->bmiHeader.biHeight-1)*linewidth);
     323        dprintf(("Flipping 1bpp bitmap and calling SetBitmapBits (WORKAROUND) (%d -> %d)", dibwidth, bmpwidth));
     324        newpix += ((pBitmapInfo->bmiHeader.biHeight-1)*bmpwidth);
    323325
    324326        //flip bitmap here; SetDIBits assumes origin is left bottom, SetBitmapBits left top
     327        //SetDIBits assumes DWORD aligned data
     328        //SetBitmapBits assumes WORD aligned data
    325329        for(int i=0;i<pBitmapInfo->bmiHeader.biHeight;i++) {
    326             memcpy(newpix, orgpix, linewidth);
    327             newpix -= linewidth;
    328             orgpix += linewidth;
     330            memcpy(newpix, orgpix, bmpwidth);
     331
     332            newpix -= bmpwidth;
     333            orgpix += dibwidth;
    329334        }
    330         newpix += linewidth;
     335        newpix += bmpwidth;
    331336        ret = O32_SetBitmapBits(hBitmap, pBitmapInfo->bmiHeader.biSizeImage, newpix);
    332337
  • trunk/src/gdi32/gdi32.cpp

    r4590 r4598  
    1 /* $Id: gdi32.cpp,v 1.61 2000-11-14 14:28:22 sandervl Exp $ */
     1/* $Id: gdi32.cpp,v 1.62 2000-11-15 16:10:41 sandervl Exp $ */
    22
    33/*
     
    118118    dprintf(("GDI32: CreateDIBPatternBrushPt %x %x", buffer, usage));
    119119    return O32_CreateDIBPatternBrushPt(buffer, usage);
     120}
     121/*****************************************************************************
     122 * Name      : HBRUSH CreateDIBPatternBrush
     123 * Purpose   : The CreateDIBPatternBrush function creates a logical brush that
     124 *             has the pattern specified by the specified device-independent
     125 *             bitmap (DIB). The brush can subsequently be selected into any
     126 *             device context that is associated with a device that supports
     127 *             raster operations.
     128 *
     129 *             This function is provided only for compatibility with applications
     130 *             written for versions of Windows earlier than 3.0. For Win32-based
     131 *             applications, use the CreateDIBPatternBrushPt function.
     132 * Parameters: HGLOBAL hglbDIBPacked Identifies a global memory object containing
     133 *             a packed DIB, which consists of a BITMAPINFO structure immediately
     134 *             followed by an array of bytes defining the pixels of the bitmap.
     135 *             UINT    fuColorSpec   color table data
     136 * Variables :
     137 * Result    : TRUE / FALSE
     138 * Remark    :
     139 * Status    : ODIN32 COMPLETELY UNTESTED
     140 *
     141 * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
     142 *             Markus Montkowski [Wen, 1999/01/12 20:00]
     143 *****************************************************************************/
     144
     145HBRUSH WIN32API CreateDIBPatternBrush( HGLOBAL hglbDIBPacked,
     146                                       UINT    fuColorSpec)
     147{
     148  BITMAPINFO *lpMem;
     149  HBRUSH ret = 0;
     150
     151  lpMem = (BITMAPINFO *)GlobalLock(hglbDIBPacked);
     152  if(NULL!=lpMem)
     153  {
     154      dprintf(("GDI32: CreateDIBPatternBrush (%08xh, %08xh) %x (%d,%d) bpp %d",
     155                hglbDIBPacked, fuColorSpec, lpMem, lpMem->bmiHeader.biWidth,
     156                lpMem->bmiHeader.biHeight, lpMem->bmiHeader.biBitCount));
     157
     158      ret = CreateDIBPatternBrushPt( lpMem,
     159                                    fuColorSpec);
     160      GlobalUnlock(hglbDIBPacked);
     161  }
     162  else {
     163      dprintf(("ERROR: CreateDIBPatternBrush (%08xh, %08xh) -> INVALID memory handle!!",
     164                hglbDIBPacked, fuColorSpec));
     165  }
     166  return (ret);
    120167}
    121168//******************************************************************************
     
    795842//******************************************************************************
    796843//******************************************************************************
    797 INT WIN32API GetPath( HDC arg1, PPOINT arg2, PBYTE arg3, int  arg4)
    798 {
    799     dprintf(("GDI32: GetPath"));
    800     return O32_GetPath(arg1, arg2, arg3, arg4);
    801 }
    802 //******************************************************************************
    803 //******************************************************************************
    804 int WIN32API GetPolyFillMode( HDC arg1)
    805 {
    806     dprintf(("GDI32: GetPolyFillMode"));
    807     return O32_GetPolyFillMode(arg1);
    808 }
    809 //******************************************************************************
    810 //******************************************************************************
    811 int WIN32API GetROP2( HDC arg1)
    812 {
    813     dprintf(("GDI32: GetROP2"));
    814     return O32_GetROP2(arg1);
     844INT WIN32API GetPath( HDC hdc, PPOINT arg2, PBYTE arg3, int  arg4)
     845{
     846    dprintf(("GDI32: GetPath %x", hdc));
     847    return O32_GetPath(hdc, arg2, arg3, arg4);
     848}
     849//******************************************************************************
     850//******************************************************************************
     851int WIN32API GetPolyFillMode( HDC hdc)
     852{
     853    dprintf(("GDI32: GetPolyFillMode", hdc));
     854    return O32_GetPolyFillMode(hdc);
     855}
     856//******************************************************************************
     857//******************************************************************************
     858int WIN32API GetROP2( HDC hdc)
     859{
     860    dprintf(("GDI32: GetROP2 %x", hdc));
     861    return O32_GetROP2(hdc);
    815862}
    816863//******************************************************************************
     
    823870//******************************************************************************
    824871//******************************************************************************
    825 UINT WIN32API GetTextAlign( HDC arg1)
    826 {
    827     dprintf(("GDI32: GetTextAlign"));
    828     return O32_GetTextAlign(arg1);
    829 }
    830 //******************************************************************************
    831 //******************************************************************************
    832 int WIN32API GetTextCharacterExtra( HDC arg1)
    833 {
    834     dprintf(("GDI32: GetTextCharacterExtra"));
    835     return O32_GetTextCharacterExtra(arg1);
    836 }
    837 //******************************************************************************
    838 //******************************************************************************
    839 COLORREF WIN32API GetTextColor( HDC arg1)
    840 {
    841     dprintf(("GDI32: GetTextColor"));
    842     return O32_GetTextColor(arg1);
     872UINT WIN32API GetTextAlign( HDC hdc)
     873{
     874    dprintf(("GDI32: GetTextAlign %x", hdc));
     875    return O32_GetTextAlign(hdc);
     876}
     877//******************************************************************************
     878//******************************************************************************
     879int WIN32API GetTextCharacterExtra( HDC hdc)
     880{
     881    dprintf(("GDI32: GetTextCharacterExtra", hdc));
     882    return O32_GetTextCharacterExtra(hdc);
     883}
     884//******************************************************************************
     885//******************************************************************************
     886COLORREF WIN32API GetTextColor( HDC hdc)
     887{
     888    dprintf(("GDI32: GetTextColor %x", hdc));
     889    return O32_GetTextColor(hdc);
    843890}
    844891//******************************************************************************
     
    15521599
    15531600
    1554 /*****************************************************************************
    1555  * Name      : HBRUSH CreateDIBPatternBrush
    1556  * Purpose   : The CreateDIBPatternBrush function creates a logical brush that
    1557  *             has the pattern specified by the specified device-independent
    1558  *             bitmap (DIB). The brush can subsequently be selected into any
    1559  *             device context that is associated with a device that supports
    1560  *             raster operations.
    1561  *
    1562  *             This function is provided only for compatibility with applications
    1563  *             written for versions of Windows earlier than 3.0. For Win32-based
    1564  *             applications, use the CreateDIBPatternBrushPt function.
    1565  * Parameters: HGLOBAL hglbDIBPacked Identifies a global memory object containing
    1566  *             a packed DIB, which consists of a BITMAPINFO structure immediately
    1567  *             followed by an array of bytes defining the pixels of the bitmap.
    1568  *             UINT    fuColorSpec   color table data
    1569  * Variables :
    1570  * Result    : TRUE / FALSE
    1571  * Remark    :
    1572  * Status    : ODIN32 COMPLETELY UNTESTED
    1573  *
    1574  * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
    1575  *             Markus Montkowski [Wen, 1999/01/12 20:00]
    1576  *****************************************************************************/
    1577 
    1578 HBRUSH WIN32API CreateDIBPatternBrush( HGLOBAL hglbDIBPacked,
    1579                                        UINT    fuColorSpec)
    1580 {
    1581   LPVOID lpMem;
    1582   HBRUSH ret = 0;
    1583   dprintf(("GDI32: CreateDIBPatternBrush(%08xh, %08xh) \n",
    1584            hglbDIBPacked,
    1585            fuColorSpec));
    1586 
    1587   lpMem = GlobalLock(hglbDIBPacked);
    1588   if(NULL!=lpMem)
    1589   {
    1590 
    1591     ret = CreateDIBPatternBrushPt( lpMem,
    1592                                    fuColorSpec);
    1593     GlobalUnlock(hglbDIBPacked);
    1594   }
    1595 
    1596   return (ret);
    1597 }
    1598 
    1599 
    16001601
    16011602
Note: See TracChangeset for help on using the changeset viewer.