| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "ktx.h" | 8 #include "ktx.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkStream.h" | 10 #include "SkStream.h" |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 } | 415 } |
| 416 | 416 |
| 417 return true; | 417 return true; |
| 418 } | 418 } |
| 419 | 419 |
| 420 bool SkKTXFile::WriteBitmapToKTX(SkWStream* stream, const SkBitmap& bitmap) { | 420 bool SkKTXFile::WriteBitmapToKTX(SkWStream* stream, const SkBitmap& bitmap) { |
| 421 const SkColorType ct = bitmap.colorType(); | 421 const SkColorType ct = bitmap.colorType(); |
| 422 SkAutoLockPixels alp(bitmap); | 422 SkAutoLockPixels alp(bitmap); |
| 423 | 423 |
| 424 const int width = bitmap.width(); | 424 const int width = bitmap.width(); |
| 425 const int height = bitmap.width(); | 425 const int height = bitmap.height(); |
| 426 const uint8_t* src = reinterpret_cast<uint8_t*>(bitmap.getPixels()); | 426 const uint8_t* src = reinterpret_cast<uint8_t*>(bitmap.getPixels()); |
| 427 if (NULL == bitmap.getPixels()) { | 427 if (NULL == bitmap.getPixels()) { |
| 428 return false; | 428 return false; |
| 429 } | 429 } |
| 430 | 430 |
| 431 // First thing's first, write out the magic identifier and endianness... | 431 // First thing's first, write out the magic identifier and endianness... |
| 432 if (!stream->write(KTX_FILE_IDENTIFIER, KTX_FILE_IDENTIFIER_SIZE) || | 432 if (!stream->write(KTX_FILE_IDENTIFIER, KTX_FILE_IDENTIFIER_SIZE) || |
| 433 !stream->write(&kKTX_ENDIANNESS_CODE, 4)) { | 433 !stream->write(&kKTX_ENDIANNESS_CODE, 4)) { |
| 434 return false; | 434 return false; |
| 435 } | 435 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 for (int i = 0; i < height; ++i) { | 550 for (int i = 0; i < height; ++i) { |
| 551 if (!stream->write(rowPtr, bpp*width)) { | 551 if (!stream->write(rowPtr, bpp*width)) { |
| 552 return false; | 552 return false; |
| 553 } | 553 } |
| 554 rowPtr += bitmap.rowBytes(); | 554 rowPtr += bitmap.rowBytes(); |
| 555 } | 555 } |
| 556 } | 556 } |
| 557 | 557 |
| 558 return true; | 558 return true; |
| 559 } | 559 } |
| OLD | NEW |