jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java
changeset 41403 be56daafbeaa
parent 35648 091db1c018f5
child 44534 a076dffbc2c1
equal deleted inserted replaced
41402:9ff91b2cd7a7 41403:be56daafbeaa
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
  1232         initializeScaleTables(sampleModel.getSampleSize());
  1232         initializeScaleTables(sampleModel.getSampleSize());
  1233 
  1233 
  1234         clearAbortRequest();
  1234         clearAbortRequest();
  1235 
  1235 
  1236         processImageStarted(0);
  1236         processImageStarted(0);
  1237 
  1237         if (abortRequested()) {
  1238         try {
  1238             processWriteAborted();
  1239             write_magic();
  1239         } else {
  1240             write_IHDR();
  1240             try {
  1241 
  1241                 write_magic();
  1242             write_cHRM();
  1242                 write_IHDR();
  1243             write_gAMA();
  1243 
  1244             write_iCCP();
  1244                 write_cHRM();
  1245             write_sBIT();
  1245                 write_gAMA();
  1246             write_sRGB();
  1246                 write_iCCP();
  1247 
  1247                 write_sBIT();
  1248             write_PLTE();
  1248                 write_sRGB();
  1249 
  1249 
  1250             write_hIST();
  1250                 write_PLTE();
  1251             write_tRNS();
  1251 
  1252             write_bKGD();
  1252                 write_hIST();
  1253 
  1253                 write_tRNS();
  1254             write_pHYs();
  1254                 write_bKGD();
  1255             write_sPLT();
  1255 
  1256             write_tIME();
  1256                 write_pHYs();
  1257             write_tEXt();
  1257                 write_sPLT();
  1258             write_iTXt();
  1258                 write_tIME();
  1259             write_zTXt();
  1259                 write_tEXt();
  1260 
  1260                 write_iTXt();
  1261             writeUnknownChunks();
  1261                 write_zTXt();
  1262 
  1262 
  1263             write_IDAT(im, deflaterLevel);
  1263                 writeUnknownChunks();
  1264 
  1264 
  1265             if (abortRequested()) {
  1265                 write_IDAT(im, deflaterLevel);
  1266                 processWriteAborted();
  1266 
  1267             } else {
  1267                 if (abortRequested()) {
  1268                 // Finish up and inform the listeners we are done
  1268                     processWriteAborted();
  1269                 writeIEND();
  1269                 } else {
  1270                 processImageComplete();
  1270                     // Finish up and inform the listeners we are done
  1271             }
  1271                     writeIEND();
  1272         } catch (IOException e) {
  1272                     processImageComplete();
  1273             throw new IIOException("I/O error writing PNG file!", e);
  1273                 }
       
  1274             } catch (IOException e) {
       
  1275                 throw new IIOException("I/O error writing PNG file!", e);
       
  1276             }
  1274         }
  1277         }
  1275     }
  1278     }
  1276 }
  1279 }