Skip to content

Commit

Permalink
app complete
Browse files Browse the repository at this point in the history
  • Loading branch information
theshivamlko committed Jun 29, 2020
1 parent df3dcae commit 006fcdf
Show file tree
Hide file tree
Showing 18 changed files with 300 additions and 331 deletions.
Binary file modified android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/fonts/Avenir.ttf
Binary file not shown.
Binary file added assets/fonts/PatinioBasica.ttf
Binary file not shown.
Binary file added assets/images/splash.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 0 additions & 36 deletions lib/NeonPainter.dart

This file was deleted.

266 changes: 5 additions & 261 deletions lib/bloc/ImageFiltersBloc.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'dart:async';
import 'dart:io' as io;
import 'dart:typed_data' as typed_data;

import 'package:cyberpunkkillerapp/Pixel.dart';
import 'package:cyberpunkkillerapp/callbacks/ClickCallback.dart';
import 'package:cyberpunkkillerapp/filters/BackgroundFilter.dart';
import 'package:cyberpunkkillerapp/filters/ColoredGlitchFilter.dart';
Expand All @@ -12,7 +10,6 @@ import 'package:cyberpunkkillerapp/filters/HorizontalGlitchFilter2.dart';
import 'package:cyberpunkkillerapp/filters/MonoColorFilter.dart';
import 'package:cyberpunkkillerapp/filters/OverlayFilter.dart';
import 'package:cyberpunkkillerapp/filters/SketchFilter.dart';
import 'package:cyberpunkkillerapp/utils/ColorConstant.dart' as ColorConstant;
import 'package:cyberpunkkillerapp/utils/Utils.dart';
import 'package:flutter/material.dart' as material;
import 'package:flutter/services.dart' show rootBundle;
Expand All @@ -29,19 +26,10 @@ class ImageFiltersBloc {
img.Image photo;

Future<bool> getImage(typed_data.Uint8List imageByte) async {
print('getImage');
//await Future.delayed(Duration(seconds: 1));

// typed_data.ByteData byteData = await loadImageBundleBytes(imagePath);
// if (byteData != null) {
setImageBytes(imageByte);
mainImageUnit8List = imageByte;

// originalImageUnit8List = Uint8List(mainImageUnit8List.length);
originalImageUnit8List = mainImageUnit8List;
resultImageUnit8List.add(mainImageUnit8List);
// }

return mainImageUnit8List != null;
}

Expand All @@ -62,266 +50,24 @@ class ImageFiltersBloc {
width: canvasSize.width.toInt(), height: canvasSize.height.toInt());
}

void redFilter() async {
print('FILTER redFilter');
int xLength = photo.width;
int yLength = photo.height;
print('FILTER redFilter $xLength $yLength');

for (int dy = 0; dy < yLength; dy++) {
for (int dx = 0; dx < xLength; dx++) {
int pixel32 = photo.getPixel(dx, dy);
// int hex = abgrToArgb(pixel32);
Pixel pixel = Pixel.fromColor(material.Color(pixel32));

// print('Hex $dx $dy $hex $pixel32');
print(
'Pixel $dx $dy ${pixel.red} ${pixel.green} ${pixel.blue} ${pixel.alpha}');
}
}
}

void applyMonoFilter(material.Color color, {ClickCallback onComplete}) async {
assert(onComplete != null);
MonoColorFilter pinkFilter = MonoColorFilter(photo, color);
resultImageUnit8List = pinkFilter.applyFilter();
onComplete(true, null, null);
}

void neonPinkFilter({ClickCallback onComplete}) async {
assert(onComplete != null);
resultImageUnit8List = List();
int xLength = photo.width;
int yLength = photo.height;
int INTENSITY_FACTOR = 120;
print('FILTER neonPinkFilter $xLength $yLength');
img.Image newPhoto = img.Image(xLength, yLength);

for (int dy = 0; dy < yLength; dy++) {
for (int dx = 0; dx < xLength; dx++) {
int pixel32 = photo.getPixel(dx, dy);
Pixel pixel = Pixel.fromColor(material.Color(pixel32));
// print('OLD Pixel ${pixel.red} ${pixel.green} ${pixel.blue} ');

int intensity = (pixel.red + pixel.blue + pixel.green) ~/ 3;
Pixel newPixel;
if (intensity > INTENSITY_FACTOR) {
// apply white color
newPixel = Pixel.fromColor(ColorConstant.neonPinkColor);
} else if (intensity > 40) {
// apply grey color
// newPixel = Pixel.fromColor(material.Colors.grey);
newPixel = Pixel.fromColor(material.Colors.black);
} else {
// apply black color
newPixel = Pixel.fromColor(material.Colors.black);
}

/* print(
'Pixel $dx $dy ${pixel.red} ${pixel.green} ${pixel.blue} ${pixel.alpha}');*/

// photo.setPixelRgba(dx, dy, pixel.red, pixel.green, pixel.blue);
// print('NEW Pixel ${pixel.red} ${pixel.green} ${pixel.blue} ');
newPhoto.setPixelRgba(
dx, dy, newPixel.red, newPixel.green, newPixel.blue, 10);
}
}

print('Previous Image $mainImageUnit8List');
print('Previous Image Length ${mainImageUnit8List.length}');
print('Previous Image $mainImageUnit8List');
// mainImageUnit8List = newPhoto.getBytes(format: img.Format.rgba);
mainImageUnit8List = img.encodeJpg(newPhoto);
resultImageUnit8List.add(mainImageUnit8List);
/* String audioString = convert.base64.encode(photo.getBytes(format: img.Format.argb));*/

/* if (!file.existsSync()) file.createSync(recursive: true);
file.writeAsBytesSync(mainImageUnit8List);*/

/* print('New Image ${newPhoto.getBytes(format: img.Format.rgba)}');
print('New Image ${newPhoto.getBytes(format: img.Format.rgba).length}');
print('New Image ${newPhoto.getBytes(format: img.Format.argb)}');
print('New Image ${newPhoto.getBytes(format: img.Format.argb).length}');*/
print('New Image $mainImageUnit8List');
print('New Image Length ${mainImageUnit8List.length}');

onComplete(true, null, null);
}

void neonPurpleFilter({ClickCallback onComplete}) async {
void sketchFilter(material.Color color,
{material.Color outLineColor = material.Colors.black,
ClickCallback onComplete}) async {
assert(onComplete != null);
int xLength = photo.width;
int yLength = photo.height;
int INTENSITY_FACTOR = 120;
print('FILTER neonPurpleFilter $xLength $yLength');
img.Image newPhoto = img.Image(xLength, yLength);

for (int dy = 0; dy < yLength; dy++) {
for (int dx = 0; dx < xLength; dx++) {
int pixel32 = photo.getPixel(dx, dy);
Pixel pixel = Pixel.fromColor(material.Color(pixel32));
// print('OLD Pixel ${pixel.red} ${pixel.green} ${pixel.blue} ');

int intensity = (pixel.red + pixel.blue + pixel.green) ~/ 3;
Pixel newPixel;
if (intensity > INTENSITY_FACTOR) {
// apply white color
newPixel = Pixel.fromColor(ColorConstant.primaryColor);
} else if (intensity > 40) {
// apply grey color
// newPixel = Pixel.fromColor(material.Colors.grey);
newPixel = Pixel.fromColor(material.Colors.black);
} else {
// apply black color
newPixel = Pixel.fromColor(material.Colors.black);
}

/* print(
'Pixel $dx $dy ${pixel.red} ${pixel.green} ${pixel.blue} ${pixel.alpha}');*/

// photo.setPixelRgba(dx, dy, pixel.red, pixel.green, pixel.blue);
// print('NEW Pixel ${pixel.red} ${pixel.green} ${pixel.blue} ');
newPhoto.setPixelRgba(
dx, dy, newPixel.red, newPixel.green, newPixel.blue, 10);
}
}

print('Previous Image $mainImageUnit8List');
print('Previous Image Length ${mainImageUnit8List.length}');
print('Previous Image $mainImageUnit8List');
// mainImageUnit8List = newPhoto.getBytes(format: img.Format.rgba);
// mainImageUnit8List = img.encodeJpg(newPhoto);
resultImageUnit8List.add(img.encodeJpg(newPhoto));

print('New Image $mainImageUnit8List');
print('New Image Length ${mainImageUnit8List.length}');

onComplete(true, null, null);
}

void sketchFilter( material.Color color,{ClickCallback onComplete}) async {
assert(onComplete != null);
SketchFilter sketchFilter = SketchFilter(photo, color);
SketchFilter sketchFilter =
SketchFilter(photo, color, outLineColor: outLineColor);
resultImageUnit8List = sketchFilter.applyFilter();

onComplete(true, null, null);
}

void coloredSketchFilter({ClickCallback onComplete}) async {
assert(onComplete != null);

resultImageUnit8List = List();
int xLength = photo.width;
int yLength = photo.height;
int INTENSITY_FACTOR = 120;
print('FILTER sketchFilter $xLength $yLength');
img.Image newPhoto = img.Image(xLength, yLength);

for (int dy = 0; dy < yLength; dy++) {
for (int dx = 0; dx < xLength; dx++) {
int pixel32 = photo.getPixel(dx, dy);
Pixel pixel = Pixel.fromColor(material.Color(pixel32));
// print('OLD Pixel ${pixel.red} ${pixel.green} ${pixel.blue} ');

int intensity = (pixel.red + pixel.blue + pixel.green) ~/ 3;
Pixel newPixel;
if (intensity > INTENSITY_FACTOR) {
// apply white color
newPixel = Pixel.fromColor(material.Colors.white);
} else if (intensity > 100) {
// apply grey color
// newPixel = Pixel.fromColor(material.Colors.grey);
newPixel = Pixel.fromColor(material.Colors.green);
} else {
// apply black color
newPixel = Pixel.fromColor(material.Colors.black);
}

/* print(
'Pixel $dx $dy ${pixel.red} ${pixel.green} ${pixel.blue} ${pixel.alpha}');*/

// photo.setPixelRgba(dx, dy, pixel.red, pixel.green, pixel.blue);
// print('NEW Pixel ${pixel.red} ${pixel.green} ${pixel.blue} ');
newPhoto.setPixelRgba(
dx, dy, newPixel.red, newPixel.green, newPixel.blue, 100);
}
}

io.File file = io.File('/storage/emulated/0/ABC.jpg');
print('Previous Image $mainImageUnit8List');
print('Previous Image Length ${mainImageUnit8List.length}');
print('Previous Image $mainImageUnit8List');
// mainImageUnit8List = newPhoto.getBytes(format: img.Format.rgba);
resultImageUnit8List.add(img.encodeJpg(newPhoto));

/* String audioString = convert.base64.encode(photo.getBytes(format: img.Format.argb));*/

if (!file.existsSync()) file.createSync(recursive: true);

file.writeAsBytesSync(mainImageUnit8List);

/* print('New Image ${newPhoto.getBytes(format: img.Format.rgba)}');
print('New Image ${newPhoto.getBytes(format: img.Format.rgba).length}');
print('New Image ${newPhoto.getBytes(format: img.Format.argb)}');
print('New Image ${newPhoto.getBytes(format: img.Format.argb).length}');*/
print('New Image $mainImageUnit8List');
print('New Image Length ${mainImageUnit8List.length}');

onComplete(true, null, null);
}

void neonYellowFilter({ClickCallback onComplete}) async {
assert(onComplete != null);
int xLength = photo.width;
int yLength = photo.height;
int INTENSITY_FACTOR = 120;
print('FILTER sketchFilter $xLength $yLength');
img.Image newPhoto = img.Image(xLength, yLength);

for (int dy = 0; dy < yLength; dy++) {
for (int dx = 0; dx < xLength; dx++) {
int pixel32 = photo.getPixel(dx, dy);
Pixel pixel = Pixel.fromColor(material.Color(pixel32));
// print('OLD Pixel ${pixel.red} ${pixel.green} ${pixel.blue} ');

int intensity = (pixel.red + pixel.blue + pixel.green) ~/ 3;
Pixel newPixel;
if (intensity > INTENSITY_FACTOR) {
// apply white color
newPixel = Pixel.fromColor(material.Colors.amber);
} else if (intensity > 40) {
// apply grey color
// newPixel = Pixel.fromColor(material.Colors.grey);
newPixel = Pixel.fromColor(material.Colors.black);
} else {
// apply black color
newPixel = Pixel.fromColor(material.Colors.black);
}

/* print(
'Pixel $dx $dy ${pixel.red} ${pixel.green} ${pixel.blue} ${pixel.alpha}');*/

// photo.setPixelRgba(dx, dy, pixel.red, pixel.green, pixel.blue);
// print('NEW Pixel ${pixel.red} ${pixel.green} ${pixel.blue} ');
newPhoto.setPixelRgba(
dx, dy, newPixel.red, newPixel.green, newPixel.blue, 100);
}
}

io.File file = io.File('/storage/emulated/0/ABC.jpg');
print('Previous Image $mainImageUnit8List');
print('Previous Image Length ${mainImageUnit8List.length}');
print('Previous Image $mainImageUnit8List');
// mainImageUnit8List = newPhoto.getBytes(format: img.Format.rgba);
mainImageUnit8List = img.encodeJpg(newPhoto);

print('New Image $mainImageUnit8List');
print('New Image Length ${mainImageUnit8List.length}');

onComplete(true, null, null);
}

void neonGlitch1Filter({ClickCallback onComplete}) async {
assert(onComplete != null);

Expand Down Expand Up @@ -385,8 +131,6 @@ class ImageFiltersBloc {
OverlayFilter pinkFilter = OverlayFilter(photo, byteData);
resultImageUnit8List = pinkFilter.applyFilter();
onComplete(true, null, null);

onComplete(true, null, null);
}

void reset({ClickCallback onComplete}) {
Expand Down
11 changes: 7 additions & 4 deletions lib/filters/SketchFilter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import 'package:image/image.dart' as img;

class SketchFilter implements FilterInterface {
img.Image photo;
material.Color color;
material.Color color1;
material.Color outLineColor;

SketchFilter(this.photo, this.color);
SketchFilter(this.photo, this.color1,

{this.outLineColor = material.Colors.black});

@override
List<typed_data.Uint8List> applyFilter({onComplete}) {
Expand All @@ -30,9 +33,9 @@ class SketchFilter implements FilterInterface {
// apply white color
newPixel = Pixel.fromColor(material.Colors.white);
} else if (intensity > 100) {
newPixel = Pixel.fromColor(color);
newPixel = Pixel.fromColor(color1);
} else {
newPixel = Pixel.fromColor(material.Colors.black);
newPixel = Pixel.fromColor(outLineColor);
}

newPhoto.setPixel(dx, dy, newPixel.toColor().value);
Expand Down
Loading

0 comments on commit 006fcdf

Please sign in to comment.