Commit 130c4503 authored by Alexander Trufanov's avatar Alexander Trufanov

Static version of toQImageSilent()

Required for use in https://phabricator.kde.org/D17955

Differential Revision: https://phabricator.kde.org/D18446
parent 7bdfad83
......@@ -97,21 +97,36 @@ QImage KSaneWidget::toQImage(const QByteArray &data,
int bytes_per_line,
ImageFormat format)
{
QImage img = QImage::fromData(data, "BMP");
return img;
return toQImageSilent(data,
width,
height,
bytes_per_line,
format);
}
QImage KSaneWidget::toQImageSilent(const QByteArray &data,
int width,
int height,
int bytes_per_line,
ImageFormat format)
{
return KSaneWidget::toQImageSilent(data,
width,
height,
bytes_per_line,
(int) currentDPI(),
format);
}
QImage KSaneWidget::toQImageSilent(const QByteArray &data,
int width,
int height,
int bytes_per_line,
int dpi,
ImageFormat format)
{
return KSaneWidget::toQImage(data,
width,
height,
bytes_per_line,
format);
QImage img = QImage::fromData(data, "BMP");
return img;
}
void KSaneWidget::scanFinal()
......
......@@ -547,6 +547,16 @@ QImage KSaneWidget::toQImageSilent(const QByteArray &data,
int height,
int bytes_per_line,
ImageFormat format)
{
return KSaneWidget::toQImageSilent(data, width, height, bytes_per_line, currentDPI(), format);
}
QImage KSaneWidget::toQImageSilent(const QByteArray &data,
int width,
int height,
int bytes_per_line,
int dpi,
ImageFormat format)
{
QImage img;
int j = 0;
......@@ -619,7 +629,7 @@ QImage KSaneWidget::toQImageSilent(const QByteArray &data,
qDebug() << "Unsupported conversion";
break;
}
float dpm = currentDPI() * (1000.0 / 25.4);
float dpm = dpi * (1000.0 / 25.4);
img.setDotsPerMeterX(dpm);
img.setDotsPerMeterY(dpm);
return img;
......
......@@ -150,6 +150,26 @@ public:
int bytes_per_line,
ImageFormat format);
/**
* This is a static version of toQImageSilent() method that requires dpi as additional
* argument. Non-static version uses currentDPI() for it.
*
* @param data is the byte data containing the image.
* @param width is the width of the image in pixels.
* @param height is the height of the image in pixels.
* @param bytes_per_line is the number of bytes used per line. This might include padding
* and is probably only relevant for 'FormatBlackWhite'.
* @param format is the KSane image format of the data.
* @param dpi is the dpi value of the image.
* @return This function returns the provided image data as a QImage. */
static
QImage toQImageSilent(const QByteArray &data,
int width,
int height,
int bytes_per_line,
int dpi,
ImageFormat format);
/** This method returns the vendor name of the scanner (Same as make). */
QString vendor() const;
/** This method returns the make name of the scanner. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment