Alpha_Type_Opaque.cpp 990 B

1234567891011121314151617181920212223
  1. #if 0 // Disabled until updated to use current API.
  2. // Copyright 2019 Google LLC.
  3. // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
  4. #include "tools/fiddle/examples.h"
  5. // HASH=79146a1a41d58d22582fdc567c6ffe4e
  6. REG_FIDDLE(Alpha_Type_Opaque, 256, 64, false, 0) {
  7. void draw(SkCanvas* canvas) {
  8. SkPMColor color = SkPreMultiplyARGB(255, 50, 100, 150);
  9. SkString s;
  10. s.printf("%u %u %u %u", SkColorGetA(color), SkColorGetR(color),
  11. SkColorGetG(color), SkColorGetB(color));
  12. SkPaint paint;
  13. paint.setAntiAlias(true);
  14. canvas->drawString(s, 10, 62, paint);
  15. canvas->scale(50, 50);
  16. SkBitmap bitmap;
  17. SkImageInfo imageInfo = SkImageInfo::Make(1, 1, kN32_SkColorType, kOpaque_SkAlphaType);
  18. if (bitmap.installPixels(imageInfo, (void*) &color, imageInfo.minRowBytes())) {
  19. canvas->drawBitmap(bitmap, 0, 0);
  20. }
  21. }
  22. } // END FIDDLE
  23. #endif // Disabled until updated to use current API.