Browse Source

neon: use size transformation

pull/330/head
Nikolas Rimikis 2 years ago
parent
commit
2156165d6f
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 1
      packages/neon/neon/lib/neon.dart
  2. 7
      packages/neon/neon/lib/src/utils/push_utils.dart

1
packages/neon/neon/lib/neon.dart

@ -3,7 +3,6 @@ library neon;
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:math';
import 'dart:ui';
import 'package:bitmap/bitmap.dart';

7
packages/neon/neon/lib/src/utils/push_utils.dart

@ -95,9 +95,8 @@ class PushUtils {
final pictureInfo = await vg.loadPicture(SvgFileLoader(file), null);
const largeIconSize = 256;
final scale = min(largeIconSize / pictureInfo.size.width, largeIconSize / pictureInfo.size.height);
final scaledWidth = (pictureInfo.size.width * scale).toInt();
final scaledHeight = (pictureInfo.size.height * scale).toInt();
final scale = largeIconSize / pictureInfo.size.longestSide;
final scaledSize = pictureInfo.size * scale;
final recorder = PictureRecorder();
Canvas(recorder)
@ -107,7 +106,7 @@ class PushUtils {
pictureInfo.picture.dispose();
final image = recorder.endRecording().toImageSync(scaledWidth, scaledHeight);
final image = recorder.endRecording().toImageSync(scaledSize.width.toInt(), scaledSize.height.toInt());
final bytes = await image.toByteData(format: ImageByteFormat.png);
final bitmap = await Bitmap.fromProvider(MemoryImage(bytes!.buffer.asUint8List()));

Loading…
Cancel
Save