aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/image_decoders.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2016-03-17 13:11:01 -0400
committerPaul Gilbert2016-03-17 13:11:01 -0400
commit8a1d238fd59a6aef21f74721f039cc0375c18a24 (patch)
tree2f7c6677005ebdddb0bc77d2219251823dac3e7e /engines/titanic/image_decoders.cpp
parent5a3aa81ab628fce76a33a07dc97010bd4d439a4e (diff)
downloadscummvm-rg350-8a1d238fd59a6aef21f74721f039cc0375c18a24.tar.gz
scummvm-rg350-8a1d238fd59a6aef21f74721f039cc0375c18a24.tar.bz2
scummvm-rg350-8a1d238fd59a6aef21f74721f039cc0375c18a24.zip
TITANIC: Implemented the CJPEGDecode and CTargaDecode classes
Thank goodness for the existing ScummVM image decoders for these types.. it made implementing the classes sooooo much easier
Diffstat (limited to 'engines/titanic/image_decoders.cpp')
-rw-r--r--engines/titanic/image_decoders.cpp47
1 files changed, 40 insertions, 7 deletions
diff --git a/engines/titanic/image_decoders.cpp b/engines/titanic/image_decoders.cpp
index bf941f83b5..e6e547f009 100644
--- a/engines/titanic/image_decoders.cpp
+++ b/engines/titanic/image_decoders.cpp
@@ -24,21 +24,54 @@
namespace Titanic {
-CJPEGDecode::CJPEGDecode(const CString &name) : _width(0), _height(0) {
- _file.open(name);
-}
+void CJPEGDecode::decode(OSVideoSurface &surface, const CString &name) {
+ // Open up the resource
+ StdCWadFile file;
+ file.open(name);
+
+ // Use the ScucmmVM deoder to decode it
+ loadStream(*file.readStream());
+ const Graphics::Surface *srcSurf = getSurface();
+
+ // Resize the surface if necessary
+ if (surface.getWidth() != srcSurf->w || surface.getHeight() != srcSurf->h)
+ surface.resize(srcSurf->w, srcSurf->h);
-void CJPEGDecode::decode(OSVideoSurface &surface) {
+ // Convert the decoded surface to the correct pixel format, and then copy it over
+ surface.lock();
+ Graphics::Surface *convertedSurface = srcSurf->convertTo(surface._rawSurface->format);
+ Common::copy((byte *)convertedSurface->getPixels(), (byte *)convertedSurface->getPixels() +
+ surface.getPitch() * surface.getHeight(), (byte *)surface._rawSurface->getPixels());
+
+ delete convertedSurface;
+ surface.unlock();
}
/*------------------------------------------------------------------------*/
+void CTargaDecode::decode(OSVideoSurface &surface, const CString &name) {
+ // Open up the resource
+ StdCWadFile file;
+ file.open(name);
-CTargaDecode::CTargaDecode(const CString &name) : _width(0), _height(0) {
-}
+ // Use the ScucmmVM deoder to decode it
+ loadStream(*file.readStream());
+ const Graphics::Surface *srcSurf = getSurface();
+
+ // Resize the surface if necessary
+ if (surface.getWidth() != srcSurf->w || surface.getHeight() != srcSurf->h)
+ surface.resize(srcSurf->w, srcSurf->h);
+
+ // Convert the decoded surface to the correct pixel format, and then copy it over
+ surface.lock();
+ Graphics::Surface *convertedSurface = srcSurf->convertTo(surface._rawSurface->format);
+
+ Common::copy((byte *)convertedSurface->getPixels(), (byte *)convertedSurface->getPixels() +
+ surface.getPitch() * surface.getHeight(), (byte *)surface._rawSurface->getPixels());
-void CTargaDecode::decode(OSVideoSurface &surface) {
+ delete convertedSurface;
+ surface.unlock();
}
} // End of namespace Titanic