• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright 2009 The Android Open Source Project
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 
9 
10 #include "SkImageEncoder.h"
11 #include "SkBitmap.h"
12 #include "SkStream.h"
13 #include "SkTemplates.h"
14 
~SkImageEncoder()15 SkImageEncoder::~SkImageEncoder() {}
16 
encodeStream(SkWStream * stream,const SkBitmap & bm,int quality)17 bool SkImageEncoder::encodeStream(SkWStream* stream, const SkBitmap& bm,
18                                   int quality) {
19     quality = SkMin32(100, SkMax32(0, quality));
20     return this->onEncode(stream, bm, quality);
21 }
22 
encodeFile(const char file[],const SkBitmap & bm,int quality)23 bool SkImageEncoder::encodeFile(const char file[], const SkBitmap& bm,
24                                 int quality) {
25     quality = SkMin32(100, SkMax32(0, quality));
26     SkFILEWStream   stream(file);
27     return this->onEncode(&stream, bm, quality);
28 }
29 
EncodeFile(const char file[],const SkBitmap & bm,Type t,int quality)30 bool SkImageEncoder::EncodeFile(const char file[], const SkBitmap& bm, Type t,
31                                 int quality) {
32     SkAutoTDelete<SkImageEncoder> enc(SkImageEncoder::Create(t));
33     return enc.get() && enc.get()->encodeFile(file, bm, quality);
34 }
35 
EncodeStream(SkWStream * stream,const SkBitmap & bm,Type t,int quality)36 bool SkImageEncoder::EncodeStream(SkWStream* stream, const SkBitmap& bm, Type t,
37                                 int quality) {
38     SkAutoTDelete<SkImageEncoder> enc(SkImageEncoder::Create(t));
39     return enc.get() && enc.get()->encodeStream(stream, bm, quality);
40 }
41 
42