Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: third_party/ktx/ktx.cpp

Issue 2383523002: Fix obvious bug in KTX encoder. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698