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 23 matching lines...) Expand all Loading... |
34 sequence = false; | 34 sequence = false; |
35 fSeqVal = 0; | 35 fSeqVal = 0; |
36 } | 36 } |
37 | 37 |
38 #include "SkDevice.h" | 38 #include "SkDevice.h" |
39 | 39 |
40 bool SkSnapshot::draw(SkAnimateMaker& maker) { | 40 bool SkSnapshot::draw(SkAnimateMaker& maker) { |
41 SkASSERT(type >= 0); | 41 SkASSERT(type >= 0); |
42 SkASSERT(filename.size() > 0); | 42 SkASSERT(filename.size() > 0); |
43 SkImageEncoder* encoder = SkImageEncoder::Create((SkImageEncoder::Type) type
); | 43 SkImageEncoder* encoder = SkImageEncoder::Create((SkImageEncoder::Type) type
); |
| 44 if (!encoder) { |
| 45 return false; |
| 46 } |
| 47 SkAutoTDelete<SkImageEncoder> ad(encoder); |
44 | 48 |
45 SkString name(filename); | 49 SkString name(filename); |
46 if (sequence) { | 50 if (sequence) { |
47 char num[4] = "000"; | 51 char num[4] = "000"; |
48 num[0] = (char) (num[0] + fSeqVal / 100); | 52 num[0] = (char) (num[0] + fSeqVal / 100); |
49 num[1] = (char) (num[1] + fSeqVal / 10 % 10); | 53 num[1] = (char) (num[1] + fSeqVal / 10 % 10); |
50 num[2] = (char) (num[2] + fSeqVal % 10); | 54 num[2] = (char) (num[2] + fSeqVal % 10); |
51 name.append(num); | 55 name.append(num); |
52 if (++fSeqVal > 999) | 56 if (++fSeqVal > 999) |
53 sequence = false; | 57 sequence = false; |
54 } | 58 } |
55 if (type == SkImageEncoder::kJPEG_Type) | 59 if (type == SkImageEncoder::kJPEG_Type) |
56 name.append(".jpg"); | 60 name.append(".jpg"); |
57 else if (type == SkImageEncoder::kPNG_Type) | 61 else if (type == SkImageEncoder::kPNG_Type) |
58 name.append(".png"); | 62 name.append(".png"); |
59 encoder->encodeFile(name.c_str(), | 63 encoder->encodeFile(name.c_str(), |
60 maker.fCanvas->getDevice()->accessBitmap(false), | 64 maker.fCanvas->getDevice()->accessBitmap(false), |
61 SkScalarFloor(quality)); | 65 SkScalarFloor(quality)); |
62 return false; | 66 return false; |
63 } | 67 } |
OLD | NEW |