#include <qapplication.h>#include <qdesktopwidget.h>#include <qpaintdevice.h>#include <qpainter.h>#include "qwt_legend.h"#include "qwt_legend_item.h"#include "qwt_scale_map.h"#include "qwt_plot_rasteritem.h"Go to the source code of this file.
Classes | |
| class | QwtPlotRasterItem::PrivateData |
| struct | QwtPlotRasterItem::PrivateData::ImageCache |
Functions | |
| static QImage | toRgba (const QImage &image, int alpha) |
| static QImage toRgba | ( | const QImage & | image, |
| int | alpha | ||
| ) | [static] |
Definition at line 39 of file qwt_plot_rasteritem.cpp.
Referenced by QwtPlotRasterItem::draw().
{
if ( alpha < 0 || alpha >= 255 )
return image;
#if QT_VERSION < 0x040000
QImage alphaImage(image.size(), 32);
alphaImage.setAlphaBuffer(true);
#else
QImage alphaImage(image.size(), QImage::Format_ARGB32);
#endif
const QRgb mask1 = qRgba(0, 0, 0, alpha);
const QRgb mask2 = qRgba(255, 255, 255, 0);
const QRgb mask3 = qRgba(0, 0, 0, 255);
const int w = image.size().width();
const int h = image.size().height();
if ( image.depth() == 8 )
{
for ( int y = 0; y < h; y++ )
{
QRgb* alphaLine = (QRgb*)alphaImage.scanLine(y);
const unsigned char *line = image.scanLine(y);
for ( int x = 0; x < w; x++ )
*alphaLine++ = (image.color(*line++) & mask2) | mask1;
}
}
else if ( image.depth() == 32 )
{
for ( int y = 0; y < h; y++ )
{
QRgb* alphaLine = (QRgb*)alphaImage.scanLine(y);
const QRgb* line = (const QRgb*) image.scanLine(y);
for ( int x = 0; x < w; x++ )
{
const QRgb rgb = *line++;
if ( rgb & mask3 ) // alpha != 0
*alphaLine++ = (rgb & mask2) | mask1;
else
*alphaLine++ = rgb;
}
}
}
return alphaImage;
}
1.7.2