commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1534739 - in /commons/proper/imaging/trunk/src: changes/ main/java/org/apache/commons/imaging/formats/jpeg/ main/java/org/apache/commons/imaging/formats/jpeg/decoder/ main/java/org/apache/commons/imaging/formats/jpeg/segments/
Date Tue, 22 Oct 2013 19:24:30 GMT
Author: damjan
Date: Tue Oct 22 19:24:29 2013
New Revision: 1534739

URL: http://svn.apache.org/r1534739
Log:
And finally encapsulate the components array in SofnSegment.

Jira issue key: IMAGING-117


Modified:
    commons/proper/imaging/trunk/src/changes/changes.xml
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SofnSegment.java

Modified: commons/proper/imaging/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/changes/changes.xml?rev=1534739&r1=1534738&r2=1534739&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/changes/changes.xml (original)
+++ commons/proper/imaging/trunk/src/changes/changes.xml Tue Oct 22 19:24:29 2013
@@ -46,6 +46,9 @@ The <action> type attribute can be add,u
   <body>
 
     <release version="1.0" date="TBA" description="TBA">
+      <action issue="IMAGING-117" dev="damjan" type="fix">
+        SofnSegment.components - public mutable array.
+      </action>
       <action issue="IMAGING-116" dev="damjan" type="fix">
         GenericSegment.bytes - public mutable array.
       </action>

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java?rev=1534739&r1=1534738&r2=1534739&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
Tue Oct 22 19:24:29 2013
@@ -829,7 +829,7 @@ public class JpegImageParser extends Ima
                 boolean have3 = false;
                 boolean have4 = false;
                 boolean haveOther = false;
-                for (final SofnSegment.Component component : fSOFNSegment.components) {
+                for (final SofnSegment.Component component : fSOFNSegment.getComponents())
{
                     final int id = component.componentIdentifier;
                     if (id == 1) {
                         have1 = true;
@@ -856,7 +856,7 @@ public class JpegImageParser extends Ima
                     boolean haveC = false;
                     boolean havec = false;
                     boolean haveY = false;
-                    for (final SofnSegment.Component component : fSOFNSegment.components)
{
+                    for (final SofnSegment.Component component : fSOFNSegment.getComponents())
{
                         final int id = component.componentIdentifier;
                         if (id == 'R') {
                             haveR = true;
@@ -889,7 +889,7 @@ public class JpegImageParser extends Ima
                         int maxHorizontalSmaplingFactor = Integer.MIN_VALUE;
                         int minVerticalSamplingFactor = Integer.MAX_VALUE;
                         int maxVerticalSamplingFactor = Integer.MIN_VALUE;
-                        for (final SofnSegment.Component component : fSOFNSegment.components)
{
+                        for (final SofnSegment.Component component : fSOFNSegment.getComponents())
{
                             if (minHorizontalSamplingFactor > component.horizontalSamplingFactor)
{
                                 minHorizontalSamplingFactor = component.horizontalSamplingFactor;
                             }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java?rev=1534739&r1=1534738&r2=1534739&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
Tue Oct 22 19:24:29 2013
@@ -74,9 +74,9 @@ public class JpegDecoder extends BinaryF
             int vMax = 0;
             for (int i = 0; i < sofnSegment.numberOfComponents; i++) {
                 hMax = Math.max(hMax,
-                        sofnSegment.components[i].horizontalSamplingFactor);
+                        sofnSegment.getComponents(i).horizontalSamplingFactor);
                 vMax = Math.max(vMax,
-                        sofnSegment.components[i].verticalSamplingFactor);
+                        sofnSegment.getComponents(i).verticalSamplingFactor);
             }
             final int hSize = 8 * hMax;
             final int vSize = 8 * vMax;
@@ -268,8 +268,8 @@ public class JpegDecoder extends BinaryF
             final SosSegment.Component scanComponent = sosSegment.components[i];
             SofnSegment.Component frameComponent = null;
             for (int j = 0; j < sofnSegment.numberOfComponents; j++) {
-                if (sofnSegment.components[j].componentIdentifier == scanComponent.scanComponentSelector)
{
-                    frameComponent = sofnSegment.components[j];
+                if (sofnSegment.getComponents(j).componentIdentifier == scanComponent.scanComponentSelector)
{
+                    frameComponent = sofnSegment.getComponents(j);
                     break;
                 }
             }
@@ -294,8 +294,8 @@ public class JpegDecoder extends BinaryF
             final SosSegment.Component scanComponent = sosSegment.components[i];
             SofnSegment.Component frameComponent = null;
             for (int j = 0; j < sofnSegment.numberOfComponents; j++) {
-                if (sofnSegment.components[j].componentIdentifier == scanComponent.scanComponentSelector)
{
-                    frameComponent = sofnSegment.components[j];
+                if (sofnSegment.getComponents(j).componentIdentifier == scanComponent.scanComponentSelector)
{
+                    frameComponent = sofnSegment.getComponents(j);
                     break;
                 }
             }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SofnSegment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SofnSegment.java?rev=1534739&r1=1534738&r2=1534739&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SofnSegment.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SofnSegment.java
Tue Oct 22 19:24:29 2013
@@ -27,7 +27,7 @@ public class SofnSegment extends Segment
     public final int width, height;
     public final int numberOfComponents;
     public final int precision;
-    public final Component[] components;
+    private final Component[] components;
 
     public static class Component {
         public final int componentIdentifier;
@@ -82,6 +82,24 @@ public class SofnSegment extends Segment
             System.out.println("");
         }
     }
+    
+    /**
+     * Returns a copy of all the components.
+     * @return the components
+     */
+    public Component[] getComponents() {
+        return components.clone();
+    }
+    
+    /**
+     * Returns the component at the specified index.
+     * @param index the array index
+     * @return the component
+     */
+    public Component getComponents(final int index) {
+        return components[index];
+    }
+    
 
     @Override
     public String getDescription() {



Mime
View raw message