Changeset 8132 in josm for trunk/src/com/drew/metadata/jpeg
- Timestamp:
- 2015-03-10T01:17:39+01:00 (10 years ago)
- Location:
- trunk/src/com/drew/metadata/jpeg
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/drew/metadata/jpeg/JpegCommentDescriptor.java
r6127 r8132 1 1 /* 2 * Copyright 2002-201 2Drew Noakes2 * Copyright 2002-2015 Drew Noakes 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 16 16 * More information about this project is available at: 17 17 * 18 * http ://drewnoakes.com/code/exif/19 * http ://code.google.com/p/metadata-extractor/18 * https://drewnoakes.com/code/exif/ 19 * https://github.com/drewnoakes/metadata-extractor 20 20 */ 21 21 package com.drew.metadata.jpeg; … … 26 26 27 27 /** 28 * Provides human-readable string representations of tag values stored in a <code>JpegCommentDirectory</code>.28 * Provides human-readable string representations of tag values stored in a {@link JpegCommentDirectory}. 29 29 * 30 * @author Drew Noakes http ://drewnoakes.com30 * @author Drew Noakes https://drewnoakes.com 31 31 */ 32 32 public class JpegCommentDescriptor extends TagDescriptor<JpegCommentDirectory> … … 40 40 public String getJpegCommentDescription() 41 41 { 42 return _directory.getString(JpegCommentDirectory.TAG_ JPEG_COMMENT);42 return _directory.getString(JpegCommentDirectory.TAG_COMMENT); 43 43 } 44 44 } -
trunk/src/com/drew/metadata/jpeg/JpegCommentDirectory.java
r6127 r8132 1 1 /* 2 * Copyright 2002-201 2Drew Noakes2 * Copyright 2002-2015 Drew Noakes 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 16 16 * More information about this project is available at: 17 17 * 18 * http ://drewnoakes.com/code/exif/19 * http ://code.google.com/p/metadata-extractor/18 * https://drewnoakes.com/code/exif/ 19 * https://github.com/drewnoakes/metadata-extractor 20 20 */ 21 21 package com.drew.metadata.jpeg; … … 29 29 * Describes tags used by a JPEG file comment. 30 30 * 31 * @author Drew Noakes http ://drewnoakes.com31 * @author Drew Noakes https://drewnoakes.com 32 32 */ 33 33 public class JpegCommentDirectory extends Directory … … 37 37 * consistency with other directory types. 38 38 */ 39 public static final int TAG_ JPEG_COMMENT = 0;39 public static final int TAG_COMMENT = 0; 40 40 41 41 @NotNull … … 43 43 44 44 static { 45 _tagNameMap.put(TAG_ JPEG_COMMENT, "JpegComment");45 _tagNameMap.put(TAG_COMMENT, "JPEG Comment"); 46 46 } 47 47 … … 51 51 } 52 52 53 @Override 53 54 @NotNull 54 55 public String getName() … … 57 58 } 58 59 60 @Override 59 61 @NotNull 60 62 protected HashMap<Integer, String> getTagNameMap() -
trunk/src/com/drew/metadata/jpeg/JpegCommentReader.java
r6127 r8132 1 1 /* 2 * Copyright 2002-201 2Drew Noakes2 * Copyright 2002-2015 Drew Noakes 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 16 16 * More information about this project is available at: 17 17 * 18 * http ://drewnoakes.com/code/exif/19 * http ://code.google.com/p/metadata-extractor/18 * https://drewnoakes.com/code/exif/ 19 * https://github.com/drewnoakes/metadata-extractor 20 20 */ 21 21 package com.drew.metadata.jpeg; 22 22 23 import com.drew. lang.BufferBoundsException;24 import com.drew. lang.BufferReader;23 import com.drew.imaging.jpeg.JpegSegmentMetadataReader; 24 import com.drew.imaging.jpeg.JpegSegmentType; 25 25 import com.drew.lang.annotations.NotNull; 26 26 import com.drew.metadata.Metadata; 27 import com.drew.metadata.MetadataReader; 27 28 import java.util.Arrays; 28 29 29 30 /** 30 * Decodes the comment stored within J peg files, populating a <code>Metadata</code>object with tag values in a31 * <code>JpegCommentDirectory</code>.31 * Decodes the comment stored within JPEG files, populating a {@link Metadata} object with tag values in a 32 * {@link JpegCommentDirectory}. 32 33 * 33 * @author Drew Noakes http ://drewnoakes.com34 * @author Drew Noakes https://drewnoakes.com 34 35 */ 35 public class JpegCommentReader implements MetadataReader36 public class JpegCommentReader implements JpegSegmentMetadataReader 36 37 { 37 /** 38 * Performs the Jpeg data extraction, adding found values to the specified 39 * instance of <code>Metadata</code>. 40 */ 41 public void extract(@NotNull final BufferReader reader, @NotNull Metadata metadata) 38 @NotNull 39 public Iterable<JpegSegmentType> getSegmentTypes() 40 { 41 return Arrays.asList(JpegSegmentType.COM); 42 } 43 44 public boolean canProcess(@NotNull byte[] segmentBytes, @NotNull JpegSegmentType segmentType) 45 { 46 // The entire contents of the byte[] is the comment. There's nothing here to discriminate upon. 47 return true; 48 } 49 50 public void extract(@NotNull byte[] segmentBytes, @NotNull Metadata metadata, @NotNull JpegSegmentType segmentType) 42 51 { 43 52 JpegCommentDirectory directory = metadata.getOrCreateDirectory(JpegCommentDirectory.class); 44 53 45 try { 46 directory.setString(JpegCommentDirectory.TAG_JPEG_COMMENT, reader.getString(0, (int)reader.getLength())); 47 } catch (BufferBoundsException e) { 48 directory.addError("Exception reading JPEG comment string"); 49 } 54 // The entire contents of the directory are the comment 55 directory.setString(JpegCommentDirectory.TAG_COMMENT, new String(segmentBytes)); 50 56 } 51 57 } -
trunk/src/com/drew/metadata/jpeg/JpegComponent.java
r6127 r8132 1 1 /* 2 * Copyright 2002-201 2Drew Noakes2 * Copyright 2002-2015 Drew Noakes 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 16 16 * More information about this project is available at: 17 17 * 18 * http ://drewnoakes.com/code/exif/19 * http ://code.google.com/p/metadata-extractor/18 * https://drewnoakes.com/code/exif/ 19 * https://github.com/drewnoakes/metadata-extractor 20 20 */ 21 21 package com.drew.metadata.jpeg; … … 26 26 27 27 /** 28 * Stores information about a J pegimage component such as the component id, horiz/vert sampling factor and28 * Stores information about a JPEG image component such as the component id, horiz/vert sampling factor and 29 29 * quantization table number. 30 30 * 31 * @author Drew Noakes http ://drewnoakes.com31 * @author Drew Noakes https://drewnoakes.com 32 32 */ 33 33 public class JpegComponent implements Serializable -
trunk/src/com/drew/metadata/jpeg/JpegDescriptor.java
r6127 r8132 1 1 /* 2 * Copyright 2002-201 2Drew Noakes2 * Copyright 2002-2015 Drew Noakes 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 16 16 * More information about this project is available at: 17 17 * 18 * http ://drewnoakes.com/code/exif/19 * http ://code.google.com/p/metadata-extractor/18 * https://drewnoakes.com/code/exif/ 19 * https://github.com/drewnoakes/metadata-extractor 20 20 */ 21 21 package com.drew.metadata.jpeg; … … 29 29 * Thanks to Darrell Silver (www.darrellsilver.com) for the initial version of this class. 30 30 * 31 * @author Drew Noakes http ://drewnoakes.com31 * @author Drew Noakes https://drewnoakes.com 32 32 */ 33 33 public class JpegDescriptor extends TagDescriptor<JpegDirectory> … … 38 38 } 39 39 40 @Override 40 41 @Nullable 41 42 public String getDescription(int tagType) … … 43 44 switch (tagType) 44 45 { 45 case JpegDirectory.TAG_ JPEG_COMPRESSION_TYPE:46 case JpegDirectory.TAG_COMPRESSION_TYPE: 46 47 return getImageCompressionTypeDescription(); 47 case JpegDirectory.TAG_ JPEG_COMPONENT_DATA_1:48 case JpegDirectory.TAG_COMPONENT_DATA_1: 48 49 return getComponentDataDescription(0); 49 case JpegDirectory.TAG_ JPEG_COMPONENT_DATA_2:50 case JpegDirectory.TAG_COMPONENT_DATA_2: 50 51 return getComponentDataDescription(1); 51 case JpegDirectory.TAG_ JPEG_COMPONENT_DATA_3:52 case JpegDirectory.TAG_COMPONENT_DATA_3: 52 53 return getComponentDataDescription(2); 53 case JpegDirectory.TAG_ JPEG_COMPONENT_DATA_4:54 case JpegDirectory.TAG_COMPONENT_DATA_4: 54 55 return getComponentDataDescription(3); 55 case JpegDirectory.TAG_ JPEG_DATA_PRECISION:56 case JpegDirectory.TAG_DATA_PRECISION: 56 57 return getDataPrecisionDescription(); 57 case JpegDirectory.TAG_ JPEG_IMAGE_HEIGHT:58 case JpegDirectory.TAG_IMAGE_HEIGHT: 58 59 return getImageHeightDescription(); 59 case JpegDirectory.TAG_ JPEG_IMAGE_WIDTH:60 case JpegDirectory.TAG_IMAGE_WIDTH: 60 61 return getImageWidthDescription(); 61 62 default: … … 67 68 public String getImageCompressionTypeDescription() 68 69 { 69 Integer value = _directory.getInteger(JpegDirectory.TAG_ JPEG_COMPRESSION_TYPE);70 Integer value = _directory.getInteger(JpegDirectory.TAG_COMPRESSION_TYPE); 70 71 if (value==null) 71 72 return null; … … 93 94 public String getImageWidthDescription() 94 95 { 95 final String value = _directory.getString(JpegDirectory.TAG_ JPEG_IMAGE_WIDTH);96 final String value = _directory.getString(JpegDirectory.TAG_IMAGE_WIDTH); 96 97 if (value==null) 97 98 return null; … … 102 103 public String getImageHeightDescription() 103 104 { 104 final String value = _directory.getString(JpegDirectory.TAG_ JPEG_IMAGE_HEIGHT);105 final String value = _directory.getString(JpegDirectory.TAG_IMAGE_HEIGHT); 105 106 if (value==null) 106 107 return null; … … 111 112 public String getDataPrecisionDescription() 112 113 { 113 final String value = _directory.getString(JpegDirectory.TAG_ JPEG_DATA_PRECISION);114 final String value = _directory.getString(JpegDirectory.TAG_DATA_PRECISION); 114 115 if (value==null) 115 116 return null; … … 125 126 return null; 126 127 127 StringBuilder sb = new StringBuilder(); 128 sb.append(value.getComponentName()); 129 sb.append(" component: Quantization table "); 130 sb.append(value.getQuantizationTableNumber()); 131 sb.append(", Sampling factors "); 132 sb.append(value.getHorizontalSamplingFactor()); 133 sb.append(" horiz/"); 134 sb.append(value.getVerticalSamplingFactor()); 135 sb.append(" vert"); 136 return sb.toString(); 128 return value.getComponentName() + " component: Quantization table " + value.getQuantizationTableNumber() 129 + ", Sampling factors " + value.getHorizontalSamplingFactor() 130 + " horiz/" + value.getVerticalSamplingFactor() + " vert"; 137 131 } 138 132 } -
trunk/src/com/drew/metadata/jpeg/JpegDirectory.java
r6127 r8132 1 1 /* 2 * Copyright 2002-201 2Drew Noakes2 * Copyright 2002-2015 Drew Noakes 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 16 16 * More information about this project is available at: 17 17 * 18 * http ://drewnoakes.com/code/exif/19 * http ://code.google.com/p/metadata-extractor/18 * https://drewnoakes.com/code/exif/ 19 * https://github.com/drewnoakes/metadata-extractor 20 20 */ 21 21 package com.drew.metadata.jpeg; … … 29 29 30 30 /** 31 * Directory of tags and values for the SOF0 J pegsegment. This segment holds basic metadata about the image.31 * Directory of tags and values for the SOF0 JPEG segment. This segment holds basic metadata about the image. 32 32 * 33 * @author Darrell Silver http://www.darrellsilver.com and Drew Noakes http ://drewnoakes.com33 * @author Darrell Silver http://www.darrellsilver.com and Drew Noakes https://drewnoakes.com 34 34 */ 35 35 public class JpegDirectory extends Directory 36 36 { 37 public static final int TAG_ JPEG_COMPRESSION_TYPE = -3;37 public static final int TAG_COMPRESSION_TYPE = -3; 38 38 /** This is in bits/sample, usually 8 (12 and 16 not supported by most software). */ 39 public static final int TAG_ JPEG_DATA_PRECISION = 0;39 public static final int TAG_DATA_PRECISION = 0; 40 40 /** The image's height. Necessary for decoding the image, so it should always be there. */ 41 public static final int TAG_ JPEG_IMAGE_HEIGHT = 1;41 public static final int TAG_IMAGE_HEIGHT = 1; 42 42 /** The image's width. Necessary for decoding the image, so it should always be there. */ 43 public static final int TAG_ JPEG_IMAGE_WIDTH = 3;43 public static final int TAG_IMAGE_WIDTH = 3; 44 44 /** 45 45 * Usually 1 = grey scaled, 3 = color YcbCr or YIQ, 4 = color CMYK … … 48 48 * sampling factors (1byte) (bit 0-3 vertical., 4-7 horizontal.), 49 49 * quantization table number (1 byte). 50 * <p />50 * <p> 51 51 * This info is from http://www.funducode.com/freec/Fileformats/format3/format3b.htm 52 52 */ 53 public static final int TAG_ JPEG_NUMBER_OF_COMPONENTS = 5;53 public static final int TAG_NUMBER_OF_COMPONENTS = 5; 54 54 55 55 // NOTE! Component tag type int values must increment in steps of 1 56 56 57 /** the first of a possible 4 color components. Number of components specified in TAG_ JPEG_NUMBER_OF_COMPONENTS. */58 public static final int TAG_ JPEG_COMPONENT_DATA_1 = 6;59 /** the second of a possible 4 color components. Number of components specified in TAG_ JPEG_NUMBER_OF_COMPONENTS. */60 public static final int TAG_ JPEG_COMPONENT_DATA_2 = 7;61 /** the third of a possible 4 color components. Number of components specified in TAG_ JPEG_NUMBER_OF_COMPONENTS. */62 public static final int TAG_ JPEG_COMPONENT_DATA_3 = 8;63 /** the fourth of a possible 4 color components. Number of components specified in TAG_ JPEG_NUMBER_OF_COMPONENTS. */64 public static final int TAG_ JPEG_COMPONENT_DATA_4 = 9;57 /** the first of a possible 4 color components. Number of components specified in TAG_NUMBER_OF_COMPONENTS. */ 58 public static final int TAG_COMPONENT_DATA_1 = 6; 59 /** the second of a possible 4 color components. Number of components specified in TAG_NUMBER_OF_COMPONENTS. */ 60 public static final int TAG_COMPONENT_DATA_2 = 7; 61 /** the third of a possible 4 color components. Number of components specified in TAG_NUMBER_OF_COMPONENTS. */ 62 public static final int TAG_COMPONENT_DATA_3 = 8; 63 /** the fourth of a possible 4 color components. Number of components specified in TAG_NUMBER_OF_COMPONENTS. */ 64 public static final int TAG_COMPONENT_DATA_4 = 9; 65 65 66 66 @NotNull … … 68 68 69 69 static { 70 _tagNameMap.put(TAG_ JPEG_COMPRESSION_TYPE, "Compression Type");71 _tagNameMap.put(TAG_ JPEG_DATA_PRECISION, "Data Precision");72 _tagNameMap.put(TAG_ JPEG_IMAGE_WIDTH, "Image Width");73 _tagNameMap.put(TAG_ JPEG_IMAGE_HEIGHT, "Image Height");74 _tagNameMap.put(TAG_ JPEG_NUMBER_OF_COMPONENTS, "Number of Components");75 _tagNameMap.put(TAG_ JPEG_COMPONENT_DATA_1, "Component 1");76 _tagNameMap.put(TAG_ JPEG_COMPONENT_DATA_2, "Component 2");77 _tagNameMap.put(TAG_ JPEG_COMPONENT_DATA_3, "Component 3");78 _tagNameMap.put(TAG_ JPEG_COMPONENT_DATA_4, "Component 4");70 _tagNameMap.put(TAG_COMPRESSION_TYPE, "Compression Type"); 71 _tagNameMap.put(TAG_DATA_PRECISION, "Data Precision"); 72 _tagNameMap.put(TAG_IMAGE_WIDTH, "Image Width"); 73 _tagNameMap.put(TAG_IMAGE_HEIGHT, "Image Height"); 74 _tagNameMap.put(TAG_NUMBER_OF_COMPONENTS, "Number of Components"); 75 _tagNameMap.put(TAG_COMPONENT_DATA_1, "Component 1"); 76 _tagNameMap.put(TAG_COMPONENT_DATA_2, "Component 2"); 77 _tagNameMap.put(TAG_COMPONENT_DATA_3, "Component 3"); 78 _tagNameMap.put(TAG_COMPONENT_DATA_4, "Component 4"); 79 79 } 80 80 … … 84 84 } 85 85 86 @Override 86 87 @NotNull 87 88 public String getName() 88 89 { 89 return "J peg";90 return "JPEG"; 90 91 } 91 92 93 @Override 92 94 @NotNull 93 95 protected HashMap<Integer, String> getTagNameMap() … … 104 106 public JpegComponent getComponent(int componentNumber) 105 107 { 106 int tagType = JpegDirectory.TAG_ JPEG_COMPONENT_DATA_1 + componentNumber;108 int tagType = JpegDirectory.TAG_COMPONENT_DATA_1 + componentNumber; 107 109 return (JpegComponent)getObject(tagType); 108 110 } … … 110 112 public int getImageWidth() throws MetadataException 111 113 { 112 return getInt(JpegDirectory.TAG_ JPEG_IMAGE_WIDTH);114 return getInt(JpegDirectory.TAG_IMAGE_WIDTH); 113 115 } 114 116 115 117 public int getImageHeight() throws MetadataException 116 118 { 117 return getInt(JpegDirectory.TAG_ JPEG_IMAGE_HEIGHT);119 return getInt(JpegDirectory.TAG_IMAGE_HEIGHT); 118 120 } 119 121 120 122 public int getNumberOfComponents() throws MetadataException 121 123 { 122 return getInt(JpegDirectory.TAG_ JPEG_NUMBER_OF_COMPONENTS);124 return getInt(JpegDirectory.TAG_NUMBER_OF_COMPONENTS); 123 125 } 124 126 } -
trunk/src/com/drew/metadata/jpeg/JpegReader.java
r6127 r8132 1 1 /* 2 * Copyright 2002-201 2Drew Noakes2 * Copyright 2002-2015 Drew Noakes 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 16 16 * More information about this project is available at: 17 17 * 18 * http ://drewnoakes.com/code/exif/19 * http ://code.google.com/p/metadata-extractor/18 * https://drewnoakes.com/code/exif/ 19 * https://github.com/drewnoakes/metadata-extractor 20 20 */ 21 21 package com.drew.metadata.jpeg; 22 22 23 import com.drew.lang.BufferBoundsException; 24 import com.drew.lang.BufferReader; 23 import com.drew.imaging.jpeg.JpegSegmentMetadataReader; 24 import com.drew.imaging.jpeg.JpegSegmentType; 25 import com.drew.lang.SequentialByteArrayReader; 26 import com.drew.lang.SequentialReader; 25 27 import com.drew.lang.annotations.NotNull; 26 28 import com.drew.metadata.Metadata; 27 import com.drew.metadata.MetadataReader; 29 30 import java.io.IOException; 31 import java.util.Arrays; 28 32 29 33 /** 30 * Decodes J peg SOF0 data, populating a <code>Metadata</code> object with tag values in a <code>JpegDirectory</code>.34 * Decodes JPEG SOFn data, populating a {@link Metadata} object with tag values in a {@link JpegDirectory}. 31 35 * 32 * @author Darrell Silver http://www.darrellsilver.com and Drew Noakes http://drewnoakes.com 36 * @author Drew Noakes https://drewnoakes.com 37 * @author Darrell Silver http://www.darrellsilver.com 33 38 */ 34 public class JpegReader implements MetadataReader39 public class JpegReader implements JpegSegmentMetadataReader 35 40 { 36 /** 37 * Performs the Jpeg data extraction, adding found values to the specified 38 * instance of <code>Metadata</code>. 39 */ 40 public void extract(@NotNull final BufferReader reader, @NotNull Metadata metadata) 41 @NotNull 42 public Iterable<JpegSegmentType> getSegmentTypes() 41 43 { 44 // NOTE that some SOFn values do not exist 45 return Arrays.asList( 46 JpegSegmentType.SOF0, 47 JpegSegmentType.SOF1, 48 JpegSegmentType.SOF2, 49 JpegSegmentType.SOF3, 50 // JpegSegmentType.SOF4, 51 JpegSegmentType.SOF5, 52 JpegSegmentType.SOF6, 53 JpegSegmentType.SOF7, 54 JpegSegmentType.SOF8, 55 JpegSegmentType.SOF9, 56 JpegSegmentType.SOF10, 57 JpegSegmentType.SOF11, 58 // JpegSegmentType.SOF12, 59 JpegSegmentType.SOF13, 60 JpegSegmentType.SOF14, 61 JpegSegmentType.SOF15 62 ); 63 } 64 65 public boolean canProcess(@NotNull byte[] segmentBytes, @NotNull JpegSegmentType segmentType) 66 { 67 return true; 68 } 69 70 public void extract(@NotNull byte[] segmentBytes, @NotNull Metadata metadata, @NotNull JpegSegmentType segmentType) 71 { 72 if (metadata.containsDirectory(JpegDirectory.class)) { 73 // If this directory is already present, discontinue this operation. 74 // We only store metadata for the *first* matching SOFn segment. 75 return; 76 } 77 42 78 JpegDirectory directory = metadata.getOrCreateDirectory(JpegDirectory.class); 43 79 80 // The value of TAG_COMPRESSION_TYPE is determined by the segment type found 81 directory.setInt(JpegDirectory.TAG_COMPRESSION_TYPE, segmentType.byteValue - JpegSegmentType.SOF0.byteValue); 82 83 SequentialReader reader = new SequentialByteArrayReader(segmentBytes); 84 44 85 try { 45 // data precision 46 int dataPrecision = reader.getUInt8(JpegDirectory.TAG_JPEG_DATA_PRECISION); 47 directory.setInt(JpegDirectory.TAG_JPEG_DATA_PRECISION, dataPrecision); 48 49 // process height 50 int height = reader.getUInt16(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT); 51 directory.setInt(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT, height); 52 53 // process width 54 int width = reader.getUInt16(JpegDirectory.TAG_JPEG_IMAGE_WIDTH); 55 directory.setInt(JpegDirectory.TAG_JPEG_IMAGE_WIDTH, width); 56 57 // number of components 58 int numberOfComponents = reader.getUInt8(JpegDirectory.TAG_JPEG_NUMBER_OF_COMPONENTS); 59 directory.setInt(JpegDirectory.TAG_JPEG_NUMBER_OF_COMPONENTS, numberOfComponents); 86 directory.setInt(JpegDirectory.TAG_DATA_PRECISION, reader.getUInt8()); 87 directory.setInt(JpegDirectory.TAG_IMAGE_HEIGHT, reader.getUInt16()); 88 directory.setInt(JpegDirectory.TAG_IMAGE_WIDTH, reader.getUInt16()); 89 short componentCount = reader.getUInt8(); 90 directory.setInt(JpegDirectory.TAG_NUMBER_OF_COMPONENTS, componentCount); 60 91 61 92 // for each component, there are three bytes of data: … … 63 94 // 2 - Sampling factors: bit 0-3 vertical, 4-7 horizontal 64 95 // 3 - Quantization table number 65 int offset = 6; 66 for (int i = 0; i < numberOfComponents; i++) { 67 int componentId = reader.getUInt8(offset++); 68 int samplingFactorByte = reader.getUInt8(offset++); 69 int quantizationTableNumber = reader.getUInt8(offset++); 70 JpegComponent component = new JpegComponent(componentId, samplingFactorByte, quantizationTableNumber); 71 directory.setObject(JpegDirectory.TAG_JPEG_COMPONENT_DATA_1 + i, component); 96 for (int i = 0; i < (int)componentCount; i++) { 97 final int componentId = reader.getUInt8(); 98 final int samplingFactorByte = reader.getUInt8(); 99 final int quantizationTableNumber = reader.getUInt8(); 100 final JpegComponent component = new JpegComponent(componentId, samplingFactorByte, quantizationTableNumber); 101 directory.setObject(JpegDirectory.TAG_COMPONENT_DATA_1 + i, component); 72 102 } 73 103 74 } catch ( BufferBoundsException ex) {104 } catch (IOException ex) { 75 105 directory.addError(ex.getMessage()); 76 106 }
Note:
See TracChangeset
for help on using the changeset viewer.