OLD | NEW |
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/image/image.h" | 5 #include "ui/gfx/image/image.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 AddRepresentation(rep); | 509 AddRepresentation(rep); |
510 } | 510 } |
511 return rep->AsImageRepCocoa()->image(); | 511 return rep->AsImageRepCocoa()->image(); |
512 } | 512 } |
513 #endif | 513 #endif |
514 | 514 |
515 std::vector<unsigned char>* Image::CopyImagePNG() const { | 515 std::vector<unsigned char>* Image::CopyImagePNG() const { |
516 return new std::vector<unsigned char>(*ToImagePNG()); | 516 return new std::vector<unsigned char>(*ToImagePNG()); |
517 } | 517 } |
518 | 518 |
519 SkBitmap Image::AsBitmap() const { | |
520 return IsEmpty() ? SkBitmap() : *ToSkBitmap(); | |
521 } | |
522 | |
523 ImageSkia Image::AsImageSkia() const { | |
524 return IsEmpty() ? ImageSkia() : *ToImageSkia(); | |
525 } | |
526 | |
527 #if defined(OS_MACOSX) | |
528 NSImage* Image::AsNSImage() const { | |
529 return IsEmpty() ? nil : ToNSImage(); | |
530 } | |
531 #endif | |
532 | |
533 ImageSkia* Image::CopyImageSkia() const { | 519 ImageSkia* Image::CopyImageSkia() const { |
534 return new ImageSkia(*ToImageSkia()); | 520 return new ImageSkia(*ToImageSkia()); |
535 } | 521 } |
536 | 522 |
537 SkBitmap* Image::CopySkBitmap() const { | 523 SkBitmap* Image::CopySkBitmap() const { |
538 return new SkBitmap(*ToSkBitmap()); | 524 return new SkBitmap(*ToSkBitmap()); |
539 } | 525 } |
540 | 526 |
541 #if defined(TOOLKIT_GTK) | 527 #if defined(TOOLKIT_GTK) |
542 GdkPixbuf* Image::CopyGdkPixbuf() const { | 528 GdkPixbuf* Image::CopyGdkPixbuf() const { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 } | 584 } |
599 return it->second; | 585 return it->second; |
600 } | 586 } |
601 | 587 |
602 void Image::AddRepresentation(internal::ImageRep* rep) const { | 588 void Image::AddRepresentation(internal::ImageRep* rep) const { |
603 CHECK(storage_.get()); | 589 CHECK(storage_.get()); |
604 storage_->representations().insert(std::make_pair(rep->type(), rep)); | 590 storage_->representations().insert(std::make_pair(rep->type(), rep)); |
605 } | 591 } |
606 | 592 |
607 } // namespace gfx | 593 } // namespace gfx |
OLD | NEW |