You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

JPEG.java 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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.hslf.model.Picture;
  17. /**
  18. * Represents a JPEG picture data in a PPT file
  19. *
  20. * @author Yegor Kozlov
  21. */
  22. public final class JPEG extends Bitmap {
  23. public enum ColorSpace { rgb, cymk };
  24. private ColorSpace colorSpace = ColorSpace.rgb;
  25. /**
  26. * @return type of this picture
  27. * @see org.apache.poi.hslf.model.Picture#JPEG
  28. */
  29. public int getType(){
  30. return Picture.JPEG;
  31. }
  32. public ColorSpace getColorSpace() {
  33. return colorSpace;
  34. }
  35. public void setColorSpace(ColorSpace colorSpace) {
  36. this.colorSpace = colorSpace;
  37. }
  38. /**
  39. * JPEG signature is one of {@code 0x46A0, 0x46B0, 0x6E20, 0x6E30}
  40. *
  41. * @return JPEG signature ({@code 0x46A0, 0x46B0, 0x6E20, 0x6E30})
  42. */
  43. public int getSignature(){
  44. return (colorSpace == ColorSpace.rgb)
  45. ? (uidInstanceCount == 1 ? 0x46A0 : 0x46B0)
  46. : (uidInstanceCount == 1 ? 0x6E20 : 0x6E30);
  47. }
  48. /**
  49. * Sets the PICT signature - either {@code 0x5420} or {@code 0x5430}
  50. */
  51. public void setSignature(int signature) {
  52. switch (signature) {
  53. case 0x46A0:
  54. uidInstanceCount = 1;
  55. colorSpace = ColorSpace.rgb;
  56. break;
  57. case 0x46B0:
  58. uidInstanceCount = 2;
  59. colorSpace = ColorSpace.rgb;
  60. break;
  61. case 0x6E20:
  62. uidInstanceCount = 1;
  63. colorSpace = ColorSpace.cymk;
  64. break;
  65. case 0x6E30:
  66. uidInstanceCount = 2;
  67. colorSpace = ColorSpace.cymk;
  68. break;
  69. default:
  70. throw new IllegalArgumentException(signature+" is not a valid instance/signature value for JPEG");
  71. }
  72. }
  73. }