本文整理汇总了C++中QBitmap::convertToImage方法的典型用法代码示例。如果您正苦于以下问题:C++ QBitmap::convertToImage方法的具体用法?C++ QBitmap::convertToImage怎么用?C++ QBitmap::convertToImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBitmap
的用法示例。
在下文中一共展示了QBitmap::convertToImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qt_pm_bitmapToRegion
HRGN qt_pm_bitmapToRegion( const QBitmap& bitmap )
{
HRGN region = 0;
QImage image = bitmap.convertToImage();
const int maxrect = 256;
RECTL rects[maxrect];
HPS hps = qt_display_ps();
#define FlushSpans \
{ \
HRGN r = GpiCreateRegion( hps, n, rects ); \
if ( region ) { \
GpiCombineRegion( hps, region, region, r, CRGN_OR ); \
GpiDestroyRegion( hps, r ); \
} else { \
region = r; \
} \
}
#define AddSpan \
{ \
rects[n].xLeft = prev1; \
rects[n].yBottom = -(y+1); \
rects[n].xRight = x-1+1; \
rects[n].yTop = -y; \
n++; \
if ( n == maxrect ) { \
FlushSpans \
n = 0; \
} \
}
int n = 0;
int zero = 0x00;
int x, y;
for ( y = 0; y < image.height(); y++ ) {
uchar *line = image.scanLine(y);
int w = image.width();
uchar all = zero;
int prev1 = -1;
for ( x = 0; x < w; ) {
uchar byte = line[x/8];
if ( x > w-8 || byte != all ) {
for ( int b = 8; b > 0 && x < w; b-- ) {
if ( !(byte & 0x80) == !all ) {
// More of the same
} else {
// A change.
if ( all != zero ) {
AddSpan;
all = zero;
} else {
prev1 = x;
all = ~zero;
}
}
byte <<= 1;
x++;
}
} else {
x += 8;
}
}
if ( all != zero ) {
AddSpan;
}
}
if ( n ) {
FlushSpans;
}
if ( !region )
region = GpiCreateRegion( hps, 0, NULL );
return region;
}
示例2: qt_x11_bitmapToRegion
Region qt_x11_bitmapToRegion(const QBitmap& bitmap)
{
Region region = XCreateRegion();
QImage image = bitmap.convertToImage();
XRectangle xr;
#define AddSpan \
{ \
xr.x = prev1; \
xr.y = y; \
xr.width = x-prev1-1; \
xr.height = 1; \
XUnionRectWithRegion( &xr, region, region ); \
}
// deal with 0<->1 problem (not on X11 anymore)
int zero=0;//(qGray(image.color(0)) < qGray(image.color(1)) ? 0x00 : 0xff);
bool little = image.bitOrder() == QImage::LittleEndian;
int x, y;
for (y=0; y<image.height(); y++) {
uchar *line = image.scanLine(y);
int w = image.width();
uchar all=zero;
int prev1 = -1;
for (x=0; x<w; ) {
uchar byte = line[x/8];
if ( x>w-8 || byte!=all ) {
if ( little ) {
for ( int b=8; b>0 && x<w; b-- ) {
if ( !(byte&0x01) == !all ) {
// More of the same
} else {
// A change.
if ( all!=zero ) {
AddSpan;
all = zero;
} else {
prev1 = x;
all = ~zero;
}
}
byte >>= 1;
x++;
}
} else {
for ( int b=8; b>0 && x<w; b-- ) {
if ( !(byte&0x80) == !all ) {
// More of the same
} else {
// A change.
if ( all!=zero ) {
AddSpan;
all = zero;
} else {
prev1 = x;
all = ~zero;
}
}
byte <<= 1;
x++;
}
}
} else {
x+=8;
}
}