summaryrefslogtreecommitdiff
path: root/src/graphics
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-10-29 09:36:16 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-10-29 09:36:16 (GMT)
commite08bc6680bb766305486fdbe1d8e6cb6482993af (patch)
treef49cb18b69540d06ddc33f4f7be75370045a81c7 /src/graphics
parent9b4f710e28bd7d14bec0ce67d19d75cb6a67c5a6 (diff)
downloadpowder-e08bc6680bb766305486fdbe1d8e6cb6482993af.zip
powder-e08bc6680bb766305486fdbe1d8e6cb6482993af.tar.gz
Format: Buffer to pti, Save renderer
Diffstat (limited to 'src/graphics')
-rw-r--r--src/graphics/Graphics.cpp19
-rw-r--r--src/graphics/Graphics.h1
2 files changed, 20 insertions, 0 deletions
diff --git a/src/graphics/Graphics.cpp b/src/graphics/Graphics.cpp
index 0fa5935..11dcac3 100644
--- a/src/graphics/Graphics.cpp
+++ b/src/graphics/Graphics.cpp
@@ -32,6 +32,25 @@ VideoBuffer::VideoBuffer(VideoBuffer * old):
std::copy(old->Buffer, old->Buffer+(old->Width*old->Height), Buffer);
};
+void VideoBuffer::Resize(float factor, bool resample)
+{
+ int newWidth = ((float)Width)*factor;
+ int newHeight = ((float)Height)*factor;
+ pixel * newBuffer;
+ if(resample)
+ newBuffer = Graphics::resample_img(Buffer, Width, Height, newWidth, newHeight);
+ else
+ newBuffer = Graphics::resample_img_nn(Buffer, Width, Height, newWidth, newHeight);
+
+ if(newBuffer)
+ {
+ delete[] Buffer;
+ Buffer = newBuffer;
+ Width = newWidth;
+ Height = newHeight;
+ }
+}
+
int VideoBuffer::SetCharacter(int x, int y, int c, int r, int g, int b, int a)
{
int i, j, w, bn = 0, ba = 0;
diff --git a/src/graphics/Graphics.h b/src/graphics/Graphics.h
index edc61e2..53d3ee7 100644
--- a/src/graphics/Graphics.h
+++ b/src/graphics/Graphics.h
@@ -109,6 +109,7 @@ public:
VideoBuffer(const VideoBuffer & old);
VideoBuffer(VideoBuffer * old);
VideoBuffer(int width, int height);
+ void Resize(float factor, bool resample = false);
TPT_INLINE void BlendPixel(int x, int y, int r, int g, int b, int a)
{
#ifdef PIX32OGL