summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/graphics/Graphics.cpp20
-rw-r--r--src/graphics/Graphics.h2
-rw-r--r--src/save/LocalSaveActivity.cpp12
-rw-r--r--src/save/LocalSaveActivity.h2
-rw-r--r--src/save/ServerSaveActivity.cpp9
-rw-r--r--src/save/ServerSaveActivity.h2
6 files changed, 34 insertions, 13 deletions
diff --git a/src/graphics/Graphics.cpp b/src/graphics/Graphics.cpp
index 35120c9..b948189 100644
--- a/src/graphics/Graphics.cpp
+++ b/src/graphics/Graphics.cpp
@@ -50,20 +50,30 @@ void VideoBuffer::Resize(float factor, bool resample)
Resize(newWidth, newHeight);
}
-void VideoBuffer::Resize(int width, int height, bool resample)
+void VideoBuffer::Resize(int width, int height, bool resample, bool fixedRatio)
{
int newWidth = width;
int newHeight = height;
pixel * newBuffer;
if(newHeight == -1 && newWidth == -1)
return;
- if(newHeight == -1)
+ if(newHeight == -1 || newWidth == -1)
{
- newHeight = ((float)Height)*((float)newWidth/(float)Width);
+ if(newHeight == -1)
+ newHeight = ((float)Height)*((float)newWidth/(float)Width);
+ if(newWidth == -1)
+ newWidth = ((float)Width)*((float)newHeight/(float)Height);
}
- if(newWidth == -1)
+ else if(fixedRatio)
{
- newWidth = ((float)Width)*((float)newHeight/(float)Height);
+ //Force proportions
+ float scaleFactor = 1.0f;
+ if(Height > newHeight)
+ scaleFactor = ((float)newHeight)/((float)Height);
+ if(Width > newWidth)
+ scaleFactor = ((float)newWidth)/((float)Width);
+ newWidth = ((float)Width)*scaleFactor;
+ newHeight = ((float)Height)*scaleFactor;
}
if(resample)
newBuffer = Graphics::resample_img(Buffer, Width, Height, newWidth, newHeight);
diff --git a/src/graphics/Graphics.h b/src/graphics/Graphics.h
index 596d93d..e2ed119 100644
--- a/src/graphics/Graphics.h
+++ b/src/graphics/Graphics.h
@@ -113,7 +113,7 @@ public:
VideoBuffer(pixel * buffer, int width, int height);
VideoBuffer(int width, int height);
void Resize(float factor, bool resample = false);
- void Resize(int width, int height, bool resample = false);
+ void Resize(int width, int height, bool resample = false, bool fixedRatio = true);
TPT_INLINE void BlendPixel(int x, int y, int r, int g, int b, int a)
{
#ifdef PIX32OGL
diff --git a/src/save/LocalSaveActivity.cpp b/src/save/LocalSaveActivity.cpp
index 455b6da..0e968aa 100644
--- a/src/save/LocalSaveActivity.cpp
+++ b/src/save/LocalSaveActivity.cpp
@@ -128,12 +128,18 @@ void LocalSaveActivity::OnDraw()
}
}
-void LocalSaveActivity::OnRequestReady(void * imagePtr)
+void LocalSaveActivity::OnResponseReady(void * imagePtr)
{
- this->thumbnail = (VideoBuffer*)imagePtr;
+ if(thumbnail)
+ delete thumbnail;
+ thumbnail = (VideoBuffer*)imagePtr;
}
LocalSaveActivity::~LocalSaveActivity()
{
-
+ RequestBroker::Ref().DetachRequestListener(this);
+ if(thumbnail)
+ delete thumbnail;
+ if(callback)
+ delete callback;
} \ No newline at end of file
diff --git a/src/save/LocalSaveActivity.h b/src/save/LocalSaveActivity.h
index 51b1ec9..b58af5e 100644
--- a/src/save/LocalSaveActivity.h
+++ b/src/save/LocalSaveActivity.h
@@ -34,6 +34,6 @@ public:
void saveWrite(std::string finalFilename);
virtual void Save();
virtual void OnDraw();
- virtual void OnRequestReady(void * imagePtr);
+ virtual void OnResponseReady(void * imagePtr);
virtual ~LocalSaveActivity();
}; \ No newline at end of file
diff --git a/src/save/ServerSaveActivity.cpp b/src/save/ServerSaveActivity.cpp
index 94d609a..1e21a60 100644
--- a/src/save/ServerSaveActivity.cpp
+++ b/src/save/ServerSaveActivity.cpp
@@ -249,15 +249,20 @@ void ServerSaveActivity::OnDraw()
}
}
-void ServerSaveActivity::OnRequestReady(void * imagePtr)
+void ServerSaveActivity::OnResponseReady(void * imagePtr)
{
- this->thumbnail = (VideoBuffer *)imagePtr;
+ if(thumbnail)
+ delete thumbnail;
+ thumbnail = (VideoBuffer *)imagePtr;
}
ServerSaveActivity::~ServerSaveActivity()
{
+ RequestBroker::Ref().DetachRequestListener(this);
if(saveUploadTask)
delete saveUploadTask;
if(callback)
delete callback;
+ if(thumbnail)
+ delete thumbnail;
} \ No newline at end of file
diff --git a/src/save/ServerSaveActivity.h b/src/save/ServerSaveActivity.h
index 6143074..43411c3 100644
--- a/src/save/ServerSaveActivity.h
+++ b/src/save/ServerSaveActivity.h
@@ -29,7 +29,7 @@ public:
virtual void Save();
virtual void Exit();
virtual void OnDraw();
- virtual void OnRequestReady(void * imagePtr);
+ virtual void OnResponseReady(void * imagePtr);
virtual void OnTick(float dt);
virtual ~ServerSaveActivity();
protected: