OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkTypes.h" | 10 #include "SkTypes.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 DEFINE_GET_MEMBER(SkSnapshot); | 28 DEFINE_GET_MEMBER(SkSnapshot); |
29 | 29 |
30 SkSnapshot::SkSnapshot() | 30 SkSnapshot::SkSnapshot() |
31 { | 31 { |
32 quality = 100 * SK_Scalar1; | 32 quality = 100 * SK_Scalar1; |
33 type = (SkImageEncoder::Type) -1; | 33 type = (SkImageEncoder::Type) -1; |
34 sequence = false; | 34 sequence = false; |
35 fSeqVal = 0; | 35 fSeqVal = 0; |
36 } | 36 } |
37 | 37 |
38 #include "SkDevice.h" | |
39 | |
40 bool SkSnapshot::draw(SkAnimateMaker& maker) { | 38 bool SkSnapshot::draw(SkAnimateMaker& maker) { |
41 SkASSERT(type >= 0); | 39 SkASSERT(type >= 0); |
42 SkASSERT(filename.size() > 0); | 40 SkASSERT(filename.size() > 0); |
43 SkImageEncoder* encoder = SkImageEncoder::Create((SkImageEncoder::Type) type
); | 41 SkImageEncoder* encoder = SkImageEncoder::Create((SkImageEncoder::Type) type
); |
44 if (!encoder) { | 42 if (!encoder) { |
45 return false; | 43 return false; |
46 } | 44 } |
47 SkAutoTDelete<SkImageEncoder> ad(encoder); | 45 SkAutoTDelete<SkImageEncoder> ad(encoder); |
48 | 46 |
49 SkString name(filename); | 47 SkString name(filename); |
(...skipping 10 matching lines...) Expand all Loading... |
60 name.append(".jpg"); | 58 name.append(".jpg"); |
61 else if (type == SkImageEncoder::kPNG_Type) | 59 else if (type == SkImageEncoder::kPNG_Type) |
62 name.append(".png"); | 60 name.append(".png"); |
63 | 61 |
64 SkBitmap pixels; | 62 SkBitmap pixels; |
65 pixels.allocPixels(maker.fCanvas->imageInfo()); | 63 pixels.allocPixels(maker.fCanvas->imageInfo()); |
66 maker.fCanvas->readPixels(&pixels, 0, 0); | 64 maker.fCanvas->readPixels(&pixels, 0, 0); |
67 encoder->encodeFile(name.c_str(), pixels, SkScalarFloorToInt(quality)); | 65 encoder->encodeFile(name.c_str(), pixels, SkScalarFloorToInt(quality)); |
68 return false; | 66 return false; |
69 } | 67 } |
OLD | NEW |