Skip to content

Commit

Permalink
Merge pull request #33 from fluttercandies/patch-ios-transparent
Browse files Browse the repository at this point in the history
Patch ios transparent background with png format.
  • Loading branch information
CaiJingLong authored May 27, 2020
2 parents 9d4b067 + 4d706ed commit 20450ad
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 13 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# CHANGELOG

- [CHANGELOG](#changelog)
- [0.5.1](#051)
- [0.5.0](#050)
- [0.4.1](#041)
- [0.4.0+2](#0402)
- [0.4.0+1](#0401)
- [0.4.0](#040)
- [0.3.0](#030)
- [0.2.0](#020)
- [0.1.6](#016)
- [0.1.5](#015)
- [0.1.4](#014)
- [0.1.3](#013)
- [0.1.2](#012)
- [0.1.1](#011)
- [0.1.0](#010)

## 0.5.1

Fix some png background error.

## 0.5.0

Support add text.
Expand Down
12 changes: 6 additions & 6 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ PODS:

DEPENDENCIES:
- Flutter (from `Flutter`)
- image_editor (from `/Volumes/Samsung-T5/code/flutter/plugins/flutter_image_editor/ios/image_editor.podspec`)
- "image_picker (from `/Users/caijinglong/.pub-cache/hosted/pub.flutter-io.cn/image_picker-0.6.1+8/ios/image_picker.podspec`)"
- path_provider (from `/Users/caijinglong/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.4.0/ios/path_provider.podspec`)
- image_editor (from `/Volumes/Evo512/code/flutter/plugins/flutter_image_editor/ios/image_editor.podspec`)
- "image_picker (from `/Users/cai/.pub-cache/hosted/pub.flutter-io.cn/image_picker-0.6.1+8/ios/image_picker.podspec`)"
- path_provider (from `/Users/cai/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.4.0/ios/path_provider.podspec`)

SPEC REPOS:
trunk:
Expand All @@ -23,11 +23,11 @@ EXTERNAL SOURCES:
Flutter:
:path: Flutter
image_editor:
:path: "/Volumes/Samsung-T5/code/flutter/plugins/flutter_image_editor/ios/image_editor.podspec"
:path: "/Volumes/Evo512/code/flutter/plugins/flutter_image_editor/ios/image_editor.podspec"
image_picker:
:path: "/Users/caijinglong/.pub-cache/hosted/pub.flutter-io.cn/image_picker-0.6.1+8/ios/image_picker.podspec"
:path: "/Users/cai/.pub-cache/hosted/pub.flutter-io.cn/image_picker-0.6.1+8/ios/image_picker.podspec"
path_provider:
:path: "/Users/caijinglong/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.4.0/ios/path_provider.podspec"
:path: "/Users/cai/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.4.0/ios/path_provider.podspec"

SPEC CHECKSUMS:
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
Expand Down
3 changes: 1 addition & 2 deletions example/lib/add_text_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dart:convert';
import 'dart:typed_data';

import 'package:flutter/material.dart';
Expand Down Expand Up @@ -71,7 +70,7 @@ class _AddTextPageState extends State<AddTextPage> {
image: u,
imageEditorOption: option,
);
print(JsonEncoder.withIndent(' ').convert(option.toJson()));
print(option.toString());
this.target = MemoryImage(result);
setState(() {});
},
Expand Down
13 changes: 9 additions & 4 deletions ios/Classes/FIUIImageHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ - (void)fixOrientation {
return;
}

UIGraphicsBeginImageContextWithOptions(outImage.size, YES, outImage.scale);
// UIGraphicsBeginImageContextWithOptions(outImage.size, YES, outImage.scale);
UIGraphicsBeginImageContext(outImage.size);

[outImage
drawInRect:CGRectMake(0, 0, outImage.size.width, outImage.size.height)];
Expand All @@ -86,7 +87,8 @@ - (void)flip:(FIFlipOption *)option {

CGSize size = outImage.size;

UIGraphicsBeginImageContextWithOptions(size, YES, 1);
// UIGraphicsBeginImageContextWithOptions(size, YES, 1);
UIGraphicsBeginImageContext(outImage.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
if (!ctx) {
return;
Expand Down Expand Up @@ -147,8 +149,10 @@ - (void)rotate:(FIRotateOption *)option {
CGAffineTransform aff = CGAffineTransformMakeRotation(redians);
CGRect newRect = CGRectApplyAffineTransform(oldRect, aff);
CGSize newSize = newRect.size;

UIGraphicsBeginImageContext(outImage.size);

UIGraphicsBeginImageContextWithOptions(newSize, YES, outImage.scale);
// UIGraphicsBeginImageContextWithOptions(newSize, YES, outImage.scale);

CGContextRef ctx = UIGraphicsGetCurrentContext();
if (!ctx) {
Expand Down Expand Up @@ -274,7 +278,8 @@ - (void)addText:(FIAddTextOption *)option {
return;
}

UIGraphicsBeginImageContextWithOptions(outImage.size, YES, outImage.scale);
// UIGraphicsBeginImageContextWithOptions(outImage.size, YES, outImage.scale);
UIGraphicsBeginImageContext(outImage.size);

CGContextRef ctx = UIGraphicsGetCurrentContext();
if (!ctx) {
Expand Down
8 changes: 8 additions & 0 deletions lib/src/option/edit_options.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:collection';
import 'dart:convert';
import 'dart:io';

import 'package:flutter/foundation.dart';
Expand Down Expand Up @@ -95,6 +96,13 @@ class ImageEditorOption implements IgnoreAble {
}
return true;
}

String toString() {
final m = <String, dynamic>{};
m['options'] = toJson();
m['fmt'] = outputFormat.toJson();
return JsonEncoder.withIndent(' ').convert(m);
}
}

class OptionGroup extends ListBase<Option> implements IgnoreAble {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: image_editor
description: Rotate ,flip, crop your image. Use objc/kotlin to handle it.
version: 0.5.0
version: 0.5.1
author: Caijinglong<cjl_spy@163.com>
homepage: https://github.com/fluttercandies/flutter_image_editor

Expand Down

0 comments on commit 20450ad

Please sign in to comment.