View Javadoc
1   /*
2    * Copyright 2015 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.commons.imaging.formats.jpeg.specific;
18  
19  import static org.junit.jupiter.api.Assertions.assertEquals;
20  
21  import java.awt.image.BufferedImage;
22  import java.io.File;
23  import java.io.IOException;
24  
25  import org.apache.commons.imaging.ImagingException;
26  import org.apache.commons.imaging.bytesource.ByteSource;
27  import org.apache.commons.imaging.formats.jpeg.JpegImageParser;
28  import org.apache.commons.imaging.test.TestResources;
29  import org.junit.jupiter.api.Test;
30  
31  /**
32   * Basic tests for JpegImageParser.
33   */
34  public class JpegImageParserTest {
35      /**
36       * Image created with The Gimp 2.8
37       *
38       * @throws ImagingException
39       * @throws IOException
40       */
41      @Test
42      public void testGetBufferedImage10() throws ImagingException, IOException {
43          final File imageFile = TestResources.resourceToFile("/IMAGING-136/1402522741337.jpg");
44          final JpegImageParser parser = new JpegImageParser();
45          final BufferedImage image = parser.getBufferedImage(ByteSource.file(imageFile), null);
46          assertEquals(680, image.getWidth());
47          assertEquals(241, image.getHeight());
48          assertEquals(-16777216, image.getRGB(0, 0));
49          assertEquals(-12177367, image.getRGB(198, 13));
50      }
51  }