Images are written by PictureRenderer and not render_pictures_main.
Review URL: https://codereview.appspot.com/6448174
git-svn-id: http://skia.googlecode.com/svn/trunk@5216 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp
index 290c79a..46b2681 100644
--- a/tools/PictureRenderer.cpp
+++ b/tools/PictureRenderer.cpp
@@ -9,8 +9,10 @@
#include "SamplePipeControllers.h"
#include "SkCanvas.h"
#include "SkDevice.h"
+#include "SkImageEncoder.h"
#include "SkGPipe.h"
#include "SkPicture.h"
+#include "SkString.h"
#include "SkTDArray.h"
#include "SkTypes.h"
#include "picture_utils.h"
@@ -109,6 +111,22 @@
#endif
}
+bool PictureRenderer::write(const SkString& path) const {
+ SkASSERT(fCanvas.get() != NULL);
+ SkASSERT(fPicture != NULL);
+ if (NULL == fCanvas.get() || NULL == fPicture) {
+ return false;
+ }
+
+ SkBitmap bitmap;
+ sk_tools::setup_bitmap(&bitmap, fPicture->width(), fPicture->height());
+
+ fCanvas->readPixels(&bitmap, 0, 0);
+ sk_tools::force_all_opaque(bitmap);
+
+ return SkImageEncoder::EncodeFile(path.c_str(), bitmap, SkImageEncoder::kPNG_Type, 100);
+}
+
void PipePictureRenderer::render() {
SkASSERT(fCanvas.get() != NULL);
SkASSERT(fPicture != NULL);