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

Side by Side Diff: ui/gfx/codec/png_codec.cc

Issue 12313139: captureVisibleTab Extension API producing garbled PNG results (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: re-added properly cast dcheck Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « AUTHORS ('k') | ui/gfx/codec/png_codec_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/codec/png_codec.h" 5 #include "ui/gfx/codec/png_codec.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "ui/gfx/size.h" 9 #include "ui/gfx/size.h"
10 #include "ui/gfx/skia_util.h" 10 #include "ui/gfx/skia_util.h"
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 // static 761 // static
762 bool PNGCodec::EncodeBGRASkBitmap(const SkBitmap& input, 762 bool PNGCodec::EncodeBGRASkBitmap(const SkBitmap& input,
763 bool discard_transparency, 763 bool discard_transparency,
764 std::vector<unsigned char>* output) { 764 std::vector<unsigned char>* output) {
765 static const int bbp = 4; 765 static const int bbp = 4;
766 766
767 SkAutoLockPixels lock_input(input); 767 SkAutoLockPixels lock_input(input);
768 if (input.empty()) 768 if (input.empty())
769 return false; 769 return false;
770 DCHECK(input.bytesPerPixel() == bbp); 770 DCHECK(input.bytesPerPixel() == bbp);
771 DCHECK(static_cast<int>(input.rowBytes()) >= input.width() * bbp);
771 772
772 return Encode(reinterpret_cast<unsigned char*>(input.getAddr32(0, 0)), 773 return Encode(reinterpret_cast<unsigned char*>(input.getAddr32(0, 0)),
773 FORMAT_SkBitmap, Size(input.width(), input.height()), 774 FORMAT_SkBitmap, Size(input.width(), input.height()),
774 input.width() * bbp, discard_transparency, 775 static_cast<int>(input.rowBytes()), discard_transparency,
775 std::vector<Comment>(), output); 776 std::vector<Comment>(), output);
776 } 777 }
777 778
778 PNGCodec::Comment::Comment(const std::string& k, const std::string& t) 779 PNGCodec::Comment::Comment(const std::string& k, const std::string& t)
779 : key(k), text(t) { 780 : key(k), text(t) {
780 } 781 }
781 782
782 PNGCodec::Comment::~Comment() { 783 PNGCodec::Comment::~Comment() {
783 } 784 }
784 785
785 } // namespace gfx 786 } // namespace gfx
OLDNEW
« no previous file with comments | « AUTHORS ('k') | ui/gfx/codec/png_codec_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698