Qt 4.8
Public Functions | Static Public Functions | Public Variables | List of all members
QNativeImage Class Reference

#include <qnativeimage_p.h>

Public Functions

int height () const
 
 QNativeImage (int width, int height, QImage::Format format, bool isTextBuffer=false, QWidget *widget=0)
 
int width () const
 
 ~QNativeImage ()
 

Static Public Functions

static QImage::Format systemFormat ()
 

Public Variables

HBITMAP bitmap
 
HDC hdc
 
QImage image
 
HBITMAP null_bitmap
 

Detailed Description

Definition at line 73 of file qnativeimage_p.h.

Constructors and Destructors

◆ QNativeImage()

QNativeImage::QNativeImage ( int  width,
int  height,
QImage::Format  format,
bool  isTextBuffer = false,
QWidget widget = 0 
)

Definition at line 73 of file qnativeimage.cpp.

Referenced by systemFormat().

74 {
75 #ifndef Q_WS_WINCE
76  Q_UNUSED(isTextBuffer);
77 #endif
78  BITMAPINFO_MASK bmi;
79  memset(&bmi, 0, sizeof(bmi));
80  bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
81  bmi.bmiHeader.biWidth = width;
82  bmi.bmiHeader.biHeight = -height;
83  bmi.bmiHeader.biPlanes = 1;
84  bmi.bmiHeader.biSizeImage = 0;
85 
87  bmi.bmiHeader.biBitCount = 16;
88 #ifdef Q_WS_WINCE
89  if (isTextBuffer) {
90  bmi.bmiHeader.biCompression = BI_RGB;
91  bmi.redMask = 0;
92  bmi.greenMask = 0;
93  bmi.blueMask = 0;
94  } else
95 #endif
96  {
97  bmi.bmiHeader.biCompression = BI_BITFIELDS;
98  bmi.redMask = 0xF800;
99  bmi.greenMask = 0x07E0;
100  bmi.blueMask = 0x001F;
101  }
102  } else {
103  bmi.bmiHeader.biBitCount = 32;
104  bmi.bmiHeader.biCompression = BI_RGB;
105  bmi.redMask = 0;
106  bmi.greenMask = 0;
107  bmi.blueMask = 0;
108  }
109 
110  HDC display_dc = GetDC(0);
111  hdc = CreateCompatibleDC(display_dc);
112  ReleaseDC(0, display_dc);
113  Q_ASSERT(hdc);
114 
115  uchar *bits = 0;
116  bitmap = CreateDIBSection(hdc, reinterpret_cast<BITMAPINFO *>(&bmi), DIB_RGB_COLORS, (void**) &bits, 0, 0);
117  Q_ASSERT(bitmap);
118  Q_ASSERT(bits);
119 
120  null_bitmap = (HBITMAP)SelectObject(hdc, bitmap);
121  image = QImage(bits, width, height, format);
122 
124  static_cast<QRasterPaintEngine *>(image.paintEngine())->setDC(hdc);
125 
126 #ifndef Q_WS_WINCE
127  GdiFlush();
128 #endif
129 }
HBITMAP null_bitmap
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
unsigned char uchar
Definition: qglobal.h:994
int width() const
virtual Type type() const =0
Reimplement this function to return the paint engine Type.
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
HBITMAP bitmap
int height() const
QPaintEngine * paintEngine() const
Used by QPainter to retrieve a paint engine for the image.
Definition: qimage.cpp:5970
The QRasterPaintEngine class enables hardware acceleration of painting operations in Qt for Embedded ...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
BITMAPINFOHEADER bmiHeader

◆ ~QNativeImage()

QNativeImage::~QNativeImage ( )

Definition at line 131 of file qnativeimage.cpp.

Referenced by systemFormat().

132 {
133  if (bitmap || hdc) {
134  Q_ASSERT(hdc);
135  Q_ASSERT(bitmap);
136  if (null_bitmap)
137  SelectObject(hdc, null_bitmap);
138  DeleteDC(hdc);
139  DeleteObject(bitmap);
140  }
141 }
HBITMAP null_bitmap
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
HBITMAP bitmap

Functions

◆ height()

int QNativeImage::height ( ) const
inline

Definition at line 105 of file qnativeimage_p.h.

Referenced by QFontEngineWin::alphaMapForGlyph(), QFontEngineWin::alphaRGBMapForGlyph(), QNativeImage(), and systemFormat().

105 { return image.height(); }
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572

◆ systemFormat()

QImage::Format QNativeImage::systemFormat ( )
static

◆ width()

int QNativeImage::width ( ) const
inline

Definition at line 104 of file qnativeimage_p.h.

Referenced by QFontEngineWin::alphaMapForGlyph(), QFontEngineWin::alphaRGBMapForGlyph(), QNativeImage(), and systemFormat().

104 { return image.width(); }
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557

Properties

◆ bitmap

HBITMAP QNativeImage::bitmap

Definition at line 88 of file qnativeimage_p.h.

Referenced by QNativeImage(), and ~QNativeImage().

◆ hdc

HDC QNativeImage::hdc

Definition at line 87 of file qnativeimage_p.h.

Referenced by QFontEngineWin::drawGDIGlyph(), QNativeImage(), and ~QNativeImage().

◆ image

QImage QNativeImage::image

◆ null_bitmap

HBITMAP QNativeImage::null_bitmap

Definition at line 89 of file qnativeimage_p.h.

Referenced by QNativeImage(), and ~QNativeImage().


The documentation for this class was generated from the following files: