Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'dart:typed_data';
- import 'package:flutter/material.dart';
- import 'dart:ui' as ui;
- void main() async {
- const double width = 800;
- const double height = 600;
- final ui.PictureRecorder recorder = new ui.PictureRecorder();
- final ui.Canvas canvas =
- new ui.Canvas(recorder, Rect.fromLTWH(0, 0, width, height));
- canvas.drawRect(
- Rect.fromLTWH(0, 0, width, height),
- Paint()
- ..style = PaintingStyle.fill
- ..color = ui.Color.fromRGBO(128, 0, 0, 1.0)
- ..isAntiAlias = false);
- final ui.Picture picture = recorder.endRecording();
- ui.Image image = await picture.toImage(width.floor(), height.floor());
- ByteData data = await image.toByteData();
- // Should be 128 as specified in our Paint fill.
- print("First pixel's R: ${data.getUint8(0)}");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement