Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

PNG.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.hslf.blip;
  16. import org.apache.poi.util.PngUtils;
  17. import org.apache.poi.hslf.model.Picture;
  18. import org.apache.poi.hslf.exceptions.HSLFException;
  19. import javax.imageio.ImageIO;
  20. import java.awt.image.BufferedImage;
  21. import java.io.ByteArrayInputStream;
  22. import java.io.IOException;
  23. /**
  24. * Represents a PNG picture data in a PPT file
  25. *
  26. * @author Yegor Kozlov
  27. */
  28. public final class PNG extends Bitmap {
  29. /**
  30. * @return PNG data
  31. */
  32. public byte[] getData() {
  33. byte[] data = super.getData();
  34. //PNG created on MAC may have a 16-byte prefix which prevents successful reading.
  35. //Just cut it off!.
  36. if (PngUtils.matchesPngHeader(data, 16)) {
  37. byte[] png = new byte[data.length-16];
  38. System.arraycopy(data, 16, png, 0, png.length);
  39. data = png;
  40. }
  41. return data;
  42. }
  43. /**
  44. * @return type of this picture
  45. * @see org.apache.poi.hslf.model.Picture#PNG
  46. */
  47. public int getType(){
  48. return Picture.PNG;
  49. }
  50. /**
  51. * PNG signature is <code>0x6E00</code>
  52. *
  53. * @return PNG signature (<code>0x6E00</code>)
  54. */
  55. public int getSignature(){
  56. return 0x6E00;
  57. }
  58. }