Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions
nsImageWin.cpp File Reference
#include "nsImageWin.h"
#include "nsRenderingContextWin.h"
#include "nsDeviceContextWin.h"
#include "imgScaler.h"
#include "nsComponentManagerUtils.h"

Go to the source code of this file.

Classes

struct  MONOBITMAPINFO
struct  ALPHA8BITMAPINFO
struct  ALPHA24BITMAPINFO
struct  ALPHA32BITMAPINFO

Defines

#define MASKBLT_ROP   MAKEROP4((DWORD)0x00AA0029, SRCCOPY)

Functions

static PRInt32 GetPlatform ()
static PRInt32 GetOsMajorVersion ()
static void CompositeBitsInMemory (HDC aTheHDC, int aDX, int aDY, int aDWidth, int aDHeight, int aSX, int aSY, int aSWidth, int aSHeight, PRInt32 aSrcy, PRUint8 *aAlphaBits, MONOBITMAPINFO *aBMI, PRUint8 *aImageBits, LPBITMAPINFOHEADER aBHead, PRInt16 aNumPaletteColors)
 
copy the mask and the image to the passed in DC, do the raster operation in memory before going to the printer

Define Documentation

#define MASKBLT_ROP   MAKEROP4((DWORD)0x00AA0029, SRCCOPY)

Definition at line 391 of file nsImageWin.cpp.


Function Documentation

void CompositeBitsInMemory ( HDC  aTheHDC,
int  aDX,
int  aDY,
int  aDWidth,
int  aDHeight,
int  aSX,
int  aSY,
int  aSWidth,
int  aSHeight,
PRInt32  aSrcy,
PRUint8 aAlphaBits,
MONOBITMAPINFO aBMI,
PRUint8 aImageBits,
LPBITMAPINFOHEADER  aBHead,
PRInt16  aNumPaletteColors 
) [static]


copy the mask and the image to the passed in DC, do the raster operation in memory before going to the printer

Definition at line 2014 of file nsImageWin.cpp.

{
  unsigned char *screenBits;

  HDC memDC = ::CreateCompatibleDC(NULL);

  if(0!=memDC){
    ALPHA24BITMAPINFO offbmi(aSWidth, aSHeight);
    HBITMAP tmpBitmap = ::CreateDIBSection(memDC, (LPBITMAPINFO)&offbmi, DIB_RGB_COLORS,
                                           (LPVOID *)&screenBits, NULL, 0);

    if(0 != tmpBitmap){
      HBITMAP oldBitmap = (HBITMAP)::SelectObject(memDC, tmpBitmap);

      if(0!=oldBitmap) {
        // pop in the alpha channel
        ::StretchDIBits(memDC, 0, 0, aSWidth, aSHeight,
                        aSX, aSrcy, aSWidth, aSHeight,
                        aAlphaBits, (LPBITMAPINFO)aBMI,
                        DIB_RGB_COLORS, SRCCOPY); 

        // paint in the image
        ::StretchDIBits(memDC, 0, 0, aSWidth, aSHeight,
                        aSX, aSrcy, aSWidth, aSHeight,
                        aImageBits, (LPBITMAPINFO)aBHead,
                        256 == aNumPaletteColors ? DIB_PAL_COLORS : DIB_RGB_COLORS,
                        SRCPAINT);

        ::GdiFlush();

        // output the composed image
#ifdef _MSC_VER
        __try {
#endif
           ::StretchDIBits(aTheHDC, aDX, aDY, aDWidth, aDHeight,
                          aSX, aSrcy, aSWidth, aSHeight,
                          screenBits, (LPBITMAPINFO)&offbmi,
                          256 == aNumPaletteColors ? DIB_PAL_COLORS : DIB_RGB_COLORS,
                          SRCCOPY);
#ifdef _MSC_VER
        }  __except (EXCEPTION_EXECUTE_HANDLER) {
          /* yeah this is ugly - certain printer drivers crash in the StretchDIBits */
          /* workaround is to subtract one from aSrcy */  
          ::StretchDIBits(aTheHDC, aDX, aDY, aDWidth, aDHeight,
                          aSX, aSrcy-1, aSWidth, aSHeight,
                          screenBits, (LPBITMAPINFO)&offbmi,
                          256 == aNumPaletteColors ? DIB_PAL_COLORS : DIB_RGB_COLORS,
                          SRCCOPY);
        }
#endif

        ::SelectObject(memDC, oldBitmap);
      }
      ::DeleteObject(tmpBitmap);
    }
    ::DeleteDC(memDC);
  }
}

Here is the caller graph for this function:

static PRInt32 GetOsMajorVersion ( ) [static]

Definition at line 56 of file nsImageWin.cpp.

{
  OSVERSIONINFO versionInfo;

  versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
  ::GetVersionEx(&versionInfo);
  return versionInfo.dwMajorVersion;
}
static PRInt32 GetPlatform ( ) [static]

Definition at line 46 of file nsImageWin.cpp.

{
  OSVERSIONINFO versionInfo;


  versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
  ::GetVersionEx(&versionInfo);
  return versionInfo.dwPlatformId;
}

Here is the caller graph for this function: