1
/* libs/graphics/animator/SkSnapshot.cpp
3
** Copyright 2006, The Android Open Source Project
5
** Licensed under the Apache License, Version 2.0 (the "License");
6
** you may not use this file except in compliance with the License.
7
** You may obtain a copy of the License at
9
** http://www.apache.org/licenses/LICENSE-2.0
11
** Unless required by applicable law or agreed to in writing, software
12
** distributed under the License is distributed on an "AS IS" BASIS,
13
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
** See the License for the specific language governing permissions and
15
** limitations under the License.
20
#include "SkSnapshot.h"
21
#include "SkAnimateMaker.h"
24
#if SK_USE_CONDENSED_INFO == 0
26
const SkMemberInfo SkSnapshot::fInfo[] = {
27
SK_MEMBER(filename, String),
28
SK_MEMBER(quality, Float),
29
SK_MEMBER(sequence, Boolean),
30
SK_MEMBER(type, BitmapEncoding)
35
DEFINE_GET_MEMBER(SkSnapshot);
37
SkSnapshot::SkSnapshot()
39
quality = 100 * SK_Scalar1;
40
type = (SkImageEncoder::Type) -1;
47
bool SkSnapshot::draw(SkAnimateMaker& maker) {
49
SkASSERT(filename.size() > 0);
50
SkImageEncoder* encoder = SkImageEncoder::Create((SkImageEncoder::Type) type);
52
SkString name(filename);
55
num[0] = (char) (num[0] + fSeqVal / 100);
56
num[1] = (char) (num[1] + fSeqVal / 10 % 10);
57
num[2] = (char) (num[2] + fSeqVal % 10);
62
if (type == SkImageEncoder::kJPEG_Type)
64
else if (type == SkImageEncoder::kPNG_Type)
66
encoder->encodeFile(name.c_str(),
67
maker.fCanvas->getDevice()->accessBitmap(false),
68
SkScalarFloor(quality));