summaryrefslogtreecommitdiff
path: root/src/search/Thumbnail.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-07-31 18:49:08 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-07-31 18:49:08 (GMT)
commit1d258eab6b0ec3740d634f014af5dbff882e0069 (patch)
tree956d446f144415d4f188dcca17c7dffba08851c2 /src/search/Thumbnail.cpp
parent303b546ceb134df48763730cbfd8ce7b6df008a2 (diff)
downloadpowder-1d258eab6b0ec3740d634f014af5dbff882e0069.zip
powder-1d258eab6b0ec3740d634f014af5dbff882e0069.tar.gz
ThumbnailBroker for background retrieval and rendering
Diffstat (limited to 'src/search/Thumbnail.cpp')
-rw-r--r--src/search/Thumbnail.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/search/Thumbnail.cpp b/src/search/Thumbnail.cpp
index 6a97a08..60c6b2b 100644
--- a/src/search/Thumbnail.cpp
+++ b/src/search/Thumbnail.cpp
@@ -42,6 +42,33 @@ Thumbnail::Thumbnail(int _id, int _datestamp, pixel * _data, ui::Point _size):
}
}
+void Thumbnail::Resize(int width, int height)
+{
+ Resize(ui::Point(width, height));
+}
+
+void Thumbnail::Resize(ui::Point newSize)
+{
+ float scaleFactorX = 1.0f, scaleFactorY = 1.0f;
+ if(Size.Y > newSize.Y)
+ {
+ scaleFactorY = float(newSize.Y)/((float)Size.Y);
+ }
+ if(Size.X > newSize.X)
+ {
+ scaleFactorX = float(newSize.X)/((float)Size.X);
+ }
+ if(scaleFactorY < 1.0f || scaleFactorX < 1.0f)
+ {
+ float scaleFactor = scaleFactorY < scaleFactorX ? scaleFactorY : scaleFactorX;
+ pixel * thumbData = Data;
+ Data = Graphics::resample_img(thumbData, Size.X, Size.Y, Size.X * scaleFactor, Size.Y * scaleFactor);
+ Size.X *= scaleFactor;
+ Size.Y *= scaleFactor;
+ free(thumbData);
+ }
+}
+
Thumbnail::~Thumbnail()
{
if(Data)