mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-30 22:51:16 +01:00
Optimization
This commit is contained in:
parent
fa1025ea15
commit
0a87c06b0d
@ -340,17 +340,21 @@ bool LBLFile::loadRasterTable(Handle &hdl, quint32 offset, quint32 size,
|
||||
return true;
|
||||
}
|
||||
|
||||
QImage LBLFile::readImage(Handle &hdl, quint32 id) const
|
||||
QPixmap LBLFile::image(Handle &hdl, quint32 id) const
|
||||
{
|
||||
QPixmap pm;
|
||||
|
||||
if (id >= _imgCount)
|
||||
return QImage();
|
||||
return pm;
|
||||
|
||||
if (!seek(hdl, _imgOffset + _rasters[id].offset))
|
||||
return QImage();
|
||||
return pm;
|
||||
QByteArray ba;
|
||||
ba.resize(_rasters[id].size);
|
||||
if (!read(hdl, ba.data(), _rasters[id].size))
|
||||
return QImage();
|
||||
return pm;
|
||||
|
||||
return QImage::fromData(ba);
|
||||
pm.loadFromData(ba, "jpeg");
|
||||
|
||||
return pm;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef LBLFILE_H
|
||||
#define LBLFILE_H
|
||||
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
#include "common/textcodec.h"
|
||||
#include "subfile.h"
|
||||
#include "label.h"
|
||||
@ -33,7 +33,7 @@ public:
|
||||
bool capitalize = true) const;
|
||||
|
||||
quint8 imageIdSize() const {return _imgOffsetIdSize;}
|
||||
QImage readImage(Handle &hdl, quint32 id) const;
|
||||
QPixmap image(Handle &hdl, quint32 id) const;
|
||||
|
||||
private:
|
||||
struct Image {
|
||||
|
@ -226,13 +226,13 @@ void RasterTile::drawPolygons(QPainter *painter)
|
||||
QSize size(QRectF(tl, br).toRect().size());
|
||||
|
||||
SubFile::Handle hdl(poly.raster.lbl());
|
||||
QImage img(poly.raster.lbl()->readImage(hdl, poly.raster.id()));
|
||||
qreal sx = (qreal)size.width() / (qreal)img.width();
|
||||
qreal sy = (qreal)size.height() / (qreal)img.height();
|
||||
QPixmap pm(poly.raster.lbl()->image(hdl, poly.raster.id()));
|
||||
qreal sx = (qreal)size.width() / (qreal)pm.width();
|
||||
qreal sy = (qreal)size.height() / (qreal)pm.height();
|
||||
|
||||
painter->save();
|
||||
painter->scale(sx, sy);
|
||||
painter->drawImage(QPointF(tl.x() / sx, tl.y() / sy), img);
|
||||
painter->drawPixmap(QPointF(tl.x() / sx, tl.y() / sy), pm);
|
||||
painter->restore();
|
||||
|
||||
//painter->setPen(Qt::blue);
|
||||
|
Loading…
Reference in New Issue
Block a user