From c9230fbab8fd3b6363b0e8b25be9b7131c238df4 Mon Sep 17 00:00:00 2001 From: KillerInk Date: Thu, 29 Oct 2020 19:49:38 +0100 Subject: [PATCH] save and load y coord too --- .../freed/views/VideoToneCurveProfile.java | 40 +++++++++++++------ app/src/main/res/raw/tonecurveprofiles.xml | 34 ++++++++++++---- 2 files changed, 54 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/freed/views/VideoToneCurveProfile.java b/app/src/main/java/freed/views/VideoToneCurveProfile.java index 5c8969574..b8451983e 100644 --- a/app/src/main/java/freed/views/VideoToneCurveProfile.java +++ b/app/src/main/java/freed/views/VideoToneCurveProfile.java @@ -22,13 +22,16 @@ public VideoToneCurveProfile(XmlElement element) String curve = element.findChild("rgb").getValue(); curve = curve.replace("\n","").replace(" ",""); split = curve.split(","); - rgb = new PointF[split.length]; - for (int i = 0; i < split.length; i++) { + rgb = new PointF[split.length/2]; + for (int i = 0; i < split.length; i+=2) { if (!TextUtils.isEmpty(split[i])) { float toset = Float.parseFloat(split[i]); if (toset > 1) toset = toset / 255; - rgb[i] = new PointF(toset,toset); + float toset2 = Float.parseFloat(split[i+1]); + if (toset2 > 1) + toset2 = toset2 / 255; + rgb[i/2] = new PointF(toset,toset2); //check if its in range 0-1 if not apply that range //this happens when we extract it with exiftools. it shows it as 0-255 range @@ -39,13 +42,16 @@ public VideoToneCurveProfile(XmlElement element) String curve = element.findChild("r").getValue(); curve = curve.replace("\n","").replace(" ",""); split = curve.split(","); - r = new PointF[split.length]; - for (int i = 0; i < split.length; i++) { + r = new PointF[split.length/2]; + for (int i = 0; i < split.length; i+=2) { if (!TextUtils.isEmpty(split[i])) { float toset = Float.parseFloat(split[i]); if (toset > 1) toset = toset / 255; - r[i] = new PointF(toset,toset); + float toset2 = Float.parseFloat(split[i+1]); + if (toset2 > 1) + toset2 = toset2 / 255; + r[i/2] = new PointF(toset,toset2); //check if its in range 0-1 if not apply that range //this happens when we extract it with exiftools. it shows it as 0-255 range @@ -56,13 +62,16 @@ public VideoToneCurveProfile(XmlElement element) String curve = element.findChild("g").getValue(); curve = curve.replace("\n","").replace(" ",""); split = curve.split(","); - g = new PointF[split.length]; - for (int i = 0; i < split.length; i++) { + g = new PointF[split.length/2]; + for (int i = 0; i < split.length; i+=2) { if (!TextUtils.isEmpty(split[i])) { float toset = Float.parseFloat(split[i]); if (toset > 1) toset = toset / 255; - g[i] = new PointF(toset,toset); + float toset2 = Float.parseFloat(split[i+1]); + if (toset2 > 1) + toset2 = toset2 / 255; + g[i/2] = new PointF(toset,toset2); //check if its in range 0-1 if not apply that range //this happens when we extract it with exiftools. it shows it as 0-255 range @@ -73,13 +82,16 @@ public VideoToneCurveProfile(XmlElement element) String curve = element.findChild("b").getValue(); curve = curve.replace("\n","").replace(" ",""); split = curve.split(","); - b = new PointF[split.length]; - for (int i = 0; i < split.length; i++) { + b = new PointF[split.length/2]; + for (int i = 0; i < split.length; i+=2) { if (!TextUtils.isEmpty(split[i])) { float toset = Float.parseFloat(split[i]); + float toset2 = Float.parseFloat(split[i+1]); if (toset > 1) toset = toset / 255; - b[i] = new PointF(toset,toset); + if (toset2 > 1) + toset2 = toset2 / 255; + b[i/2] = new PointF(toset,toset2); //check if its in range 0-1 if not apply that range //this happens when we extract it with exiftools. it shows it as 0-255 range @@ -94,22 +106,26 @@ public String getXmlString() for (int i=0; i < rgb.length; i++) { rgbs.append(rgb[i].x).append(","); + rgbs.append(rgb[i].y).append(","); } StringBuilder rs = new StringBuilder(); for (int i=0; i < r.length; i++) { rs.append(r[i].x).append(","); + rs.append(r[i].y).append(","); } StringBuilder gs = new StringBuilder(); for (int i=0; i < g.length; i++) { gs.append(g[i].x).append(","); + gs.append(g[i].y).append(","); } StringBuilder bs = new StringBuilder(); for (int i=0; i < b.length; i++) { bs.append(b[i].x).append(","); + bs.append(b[i].y).append(","); } String t = ""; t += "" + "\r\n"; diff --git a/app/src/main/res/raw/tonecurveprofiles.xml b/app/src/main/res/raw/tonecurveprofiles.xml index 53bb4abfd..88cade2e9 100644 --- a/app/src/main/res/raw/tonecurveprofiles.xml +++ b/app/src/main/res/raw/tonecurveprofiles.xml @@ -1,14 +1,32 @@ - 0,1 - 0,1 - 0,1 - 0,1 + 0,0,1,1 + 0,0,1,1 + 0,0,1,1 + 0,0,1,1 - 1,0 - 1,0 - 1,0 - 1,0 + 1,1,0,0 + 1,1,0,0 + 1,1,0,0 + 1,1,0,0 + + + 0.0000, 0.0000, 0.0667, 0.2864, 0.1333, 0.4007, 0.2000, 0.4845, + 0.2667, 0.5532, 0.3333, 0.6125, 0.4000, 0.6652, 0.4667, 0.7130, + 0.5333, 0.7569, 0.6000, 0.7977, 0.6667, 0.8360, 0.7333, 0.8721, + 0.8000, 0.9063, 0.8667, 0.9389, 0.9333, 0.9701, 1.0000, 1.0000 + 0,0,1,1 + 0,0,1,1 + 0,0,1,1 + + + 0.0000, 0.0000, 0.0667, 0.2920, 0.1333, 0.4002, 0.2000, 0.4812, + 0.2667, 0.5484, 0.3333, 0.6069, 0.4000, 0.6594, 0.4667, 0.7072, + 0.5333, 0.7515, 0.6000, 0.7928, 0.6667, 0.8317, 0.7333, 0.8685, + 0.8000, 0.9035, 0.8667, 0.9370, 0.9333, 0.9691, 1.0000, 1.0000 + 0,0,1,1 + 0,0,1,1 + 0,0,1,1 \ No newline at end of file