Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Unified Diff: src/images/SkDecodingImageGenerator.cpp

Issue 74793011: Add SkImageGenerator Interface (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/images/SkDecodingImageGenerator.cpp
diff --git a/src/images/SkDecodingImageGenerator.cpp b/src/images/SkDecodingImageGenerator.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a59c14a94c60c39bb14041da3cfcd788976c87a2
--- /dev/null
+++ b/src/images/SkDecodingImageGenerator.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkDecodingImageGenerator.h"
+
+#include "SkBitmapFactory.h"
+#include "SkData.h"
+#include "SkImageDecoder.h"
+
+SkDecodingImageGenerator::SkDecodingImageGenerator(SkData* data)
+ : fData(data) {
+ SkASSERT(fData != NULL);
+ fData->ref();
+}
+
+SkDecodingImageGenerator::~SkDecodingImageGenerator() {
+ fData->unref();
+}
+
+SkData* SkDecodingImageGenerator::refEncodedData() {
+ fData->ref();
+ return fData;
+}
+
+bool SkDecodingImageGenerator::getInfo(SkImageInfo* info) {
+ return SkImageDecoder::DecodeMemoryToTarget(fData->data(),
+ fData->size(),
+ info, NULL);
+}
+
+bool SkDecodingImageGenerator::getPixels(const SkImageInfo& info,
+ void* pixels,
+ size_t rowBytes) {
+ SkBitmapFactory::Target target = {pixels, rowBytes};
+ SkImageInfo tmpInfo = info;
+ return SkImageDecoder::DecodeMemoryToTarget(fData->data(),
+ fData->size(),
+ &tmpInfo, &target);
+}

Powered by Google App Engine
This is Rietveld 408576698