aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/images
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-01-06 20:16:26 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-01-06 20:16:26 +0000
commitb08eb2b3bce45411494fe00258e4c91248ccd15e (patch)
treeb20617e02fa260e8b09114a72bee7f2ade789323 /src/images
parent092590b88dd87d2fca87d38b2003068ffef37f2f (diff)
separate image encode and decode
remove obsolete build-flag for encode git-svn-id: http://skia.googlecode.com/svn/trunk@56 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/images')
-rw-r--r--src/images/SkImageDecoder.cpp33
-rw-r--r--src/images/SkImageDecoder_libjpeg.cpp5
-rw-r--r--src/images/SkImageDecoder_libpng.cpp4
-rw-r--r--src/images/SkImageEncoder.cpp48
4 files changed, 50 insertions, 40 deletions
diff --git a/src/images/SkImageDecoder.cpp b/src/images/SkImageDecoder.cpp
index 18b52d689c..2d477ef4aa 100644
--- a/src/images/SkImageDecoder.cpp
+++ b/src/images/SkImageDecoder.cpp
@@ -155,36 +155,3 @@ bool SkImageDecoder::DecodeStream(SkStream* stream, SkBitmap* bm,
return success;
}
-///////////////////////////////////////////////////////////////////////////////
-
-#ifdef SK_SUPPORT_IMAGE_ENCODE
-
-SkImageEncoder::~SkImageEncoder() {}
-
-bool SkImageEncoder::encodeStream(SkWStream* stream, const SkBitmap& bm,
- int quality) {
- quality = SkMin32(100, SkMax32(0, quality));
- return this->onEncode(stream, bm, quality);
-}
-
-bool SkImageEncoder::encodeFile(const char file[], const SkBitmap& bm,
- int quality) {
- quality = SkMin32(100, SkMax32(0, quality));
- SkFILEWStream stream(file);
- return this->onEncode(&stream, bm, quality);
-}
-
-bool SkImageEncoder::EncodeFile(const char file[], const SkBitmap& bm, Type t,
- int quality) {
- SkAutoTDelete<SkImageEncoder> enc(SkImageEncoder::Create(t));
- return enc.get() && enc.get()->encodeFile(file, bm, quality);
-}
-
-bool SkImageEncoder::EncodeStream(SkWStream* stream, const SkBitmap& bm, Type t,
- int quality) {
- SkAutoTDelete<SkImageEncoder> enc(SkImageEncoder::Create(t));
- return enc.get() && enc.get()->encodeStream(stream, bm, quality);
-}
-
-#endif
-
diff --git a/src/images/SkImageDecoder_libjpeg.cpp b/src/images/SkImageDecoder_libjpeg.cpp
index 492de2374f..51339971ac 100644
--- a/src/images/SkImageDecoder_libjpeg.cpp
+++ b/src/images/SkImageDecoder_libjpeg.cpp
@@ -15,6 +15,7 @@
*/
#include "SkImageDecoder.h"
+#include "SkImageEncoder.h"
#include "SkColorPriv.h"
#include "SkDither.h"
#include "SkScaledBitmapSampler.h"
@@ -501,8 +502,6 @@ bool SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* bm,
///////////////////////////////////////////////////////////////////////////////
-#ifdef SK_SUPPORT_IMAGE_ENCODE
-
#include "SkColorPriv.h"
// taken from jcolor.c in libjpeg
@@ -795,8 +794,6 @@ SkImageEncoder* SkImageEncoder_JPEG_Factory() {
return SkNEW(SkJPEGImageEncoder);
}
-#endif /* SK_SUPPORT_IMAGE_ENCODE */
-
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp
index 862ebf1d98..1371ecc77d 100644
--- a/src/images/SkImageDecoder_libpng.cpp
+++ b/src/images/SkImageDecoder_libpng.cpp
@@ -16,6 +16,7 @@
*/
#include "SkImageDecoder.h"
+#include "SkImageEncoder.h"
#include "SkColor.h"
#include "SkColorPriv.h"
#include "SkDither.h"
@@ -443,8 +444,6 @@ bool SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* decodedBitmap,
///////////////////////////////////////////////////////////////////////////////
-#ifdef SK_SUPPORT_IMAGE_ENCODE
-
#include "SkColorPriv.h"
#include "SkUnPreMultiply.h"
@@ -792,4 +791,3 @@ SkImageEncoder* SkImageEncoder_PNG_Factory() {
return SkNEW(SkPNGImageEncoder);
}
-#endif /* SK_SUPPORT_IMAGE_ENCODE */
diff --git a/src/images/SkImageEncoder.cpp b/src/images/SkImageEncoder.cpp
new file mode 100644
index 0000000000..d3599059d9
--- /dev/null
+++ b/src/images/SkImageEncoder.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2009, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SkImageEncoder.h"
+#include "SkBitmap.h"
+#include "SkStream.h"
+#include "SkTemplates.h"
+
+SkImageEncoder::~SkImageEncoder() {}
+
+bool SkImageEncoder::encodeStream(SkWStream* stream, const SkBitmap& bm,
+ int quality) {
+ quality = SkMin32(100, SkMax32(0, quality));
+ return this->onEncode(stream, bm, quality);
+}
+
+bool SkImageEncoder::encodeFile(const char file[], const SkBitmap& bm,
+ int quality) {
+ quality = SkMin32(100, SkMax32(0, quality));
+ SkFILEWStream stream(file);
+ return this->onEncode(&stream, bm, quality);
+}
+
+bool SkImageEncoder::EncodeFile(const char file[], const SkBitmap& bm, Type t,
+ int quality) {
+ SkAutoTDelete<SkImageEncoder> enc(SkImageEncoder::Create(t));
+ return enc.get() && enc.get()->encodeFile(file, bm, quality);
+}
+
+bool SkImageEncoder::EncodeStream(SkWStream* stream, const SkBitmap& bm, Type t,
+ int quality) {
+ SkAutoTDelete<SkImageEncoder> enc(SkImageEncoder::Create(t));
+ return enc.get() && enc.get()->encodeStream(stream, bm, quality);
+}
+