Skip to content

Commit

Permalink
save and load y coord too
Browse files Browse the repository at this point in the history
  • Loading branch information
KillerInk committed Oct 29, 2020
1 parent ad61798 commit c9230fb
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 20 deletions.
40 changes: 28 additions & 12 deletions app/src/main/java/freed/views/VideoToneCurveProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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 += "<tonecurve name= " +String.valueOf("\"") +String.valueOf(name) +String.valueOf("\"") +">" + "\r\n";
Expand Down
34 changes: 26 additions & 8 deletions app/src/main/res/raw/tonecurveprofiles.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
<tonecurves>
<tonecurve name= "linear">
<rgb>0,1</rgb>
<r>0,1</r>
<g>0,1</g>
<b>0,1</b>
<rgb>0,0,1,1</rgb>
<r>0,0,1,1</r>
<g>0,0,1,1</g>
<b>0,0,1,1</b>
</tonecurve>
<tonecurve name="linear inverted">
<rgb>1,0</rgb>
<r>1,0</r>
<g>1,0</g>
<b>1,0</b>
<rgb>1,1,0,0</rgb>
<r>1,1,0,0</r>
<g>1,1,0,0</g>
<b>1,1,0,0</b>
</tonecurve>
<tonecurve name="srgb">
<rgb>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</rgb>
<r>0,0,1,1</r>
<g>0,0,1,1</g>
<b>0,0,1,1</b>
</tonecurve>
<tonecurve name="gamma1.2">
<rgb>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</rgb>
<r>0,0,1,1</r>
<g>0,0,1,1</g>
<b>0,0,1,1</b>
</tonecurve>
</tonecurves>

0 comments on commit c9230fb

Please sign in to comment.