SHARE
TWEET

Untitled

a guest Sep 20th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import 'dart:typed_data';
  2. import 'package:flutter/material.dart';
  3. import 'dart:ui' as ui;
  4.  
  5. void main() async {
  6.   const double width = 800;
  7.   const double height = 600;
  8.   final ui.PictureRecorder recorder = new ui.PictureRecorder();
  9.   final ui.Canvas canvas =
  10.       new ui.Canvas(recorder, Rect.fromLTWH(0, 0, width, height));
  11.  
  12.   canvas.drawRect(
  13.       Rect.fromLTWH(0, 0, width, height),
  14.       Paint()
  15.         ..style = PaintingStyle.fill
  16.         ..color = ui.Color.fromRGBO(128, 0, 0, 1.0)
  17.         ..isAntiAlias = false);
  18.   final ui.Picture picture = recorder.endRecording();
  19.   ui.Image image = await picture.toImage(width.floor(), height.floor());
  20.   ByteData data = await image.toByteData();
  21.  
  22.   // Should be 128 as specified in our Paint fill.
  23.   print("First pixel's R: ${data.getUint8(0)}");
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top