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.

AFPImageHandlerRawCCITTFax.java 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.render.afp;
  19. import java.io.IOException;
  20. import org.apache.fop.afp.AFPDataObjectInfo;
  21. import org.apache.fop.afp.AFPImageObjectInfo;
  22. import org.apache.fop.afp.AFPObjectAreaInfo;
  23. import org.apache.xmlgraphics.image.loader.ImageFlavor;
  24. import org.apache.xmlgraphics.image.loader.ImageSize;
  25. import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax;
  26. /**
  27. * PDFImageHandler implementation which handles CCITT encoded images (CCITT fax group 3/4).
  28. */
  29. public class AFPImageHandlerRawCCITTFax extends AFPImageHandler {
  30. private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
  31. ImageFlavor.RAW_CCITTFAX,
  32. };
  33. private static final Class[] CLASSES = new Class[] {
  34. ImageRawCCITTFax.class,
  35. };
  36. /** {@inheritDoc} */
  37. public AFPDataObjectInfo generateDataObjectInfo(
  38. AFPRendererImageInfo rendererImageInfo) throws IOException {
  39. AFPImageObjectInfo imageObjectInfo
  40. = (AFPImageObjectInfo)super.generateDataObjectInfo(rendererImageInfo);
  41. ImageRawCCITTFax ccitt = (ImageRawCCITTFax) rendererImageInfo.getImage();
  42. imageObjectInfo.setCompression(ccitt.getCompression());
  43. AFPObjectAreaInfo objectAreaInfo = imageObjectInfo.getObjectAreaInfo();
  44. ImageSize imageSize = ccitt.getSize();
  45. int widthRes = (int) (imageSize.getDpiHorizontal() * 10);
  46. objectAreaInfo.setWidthRes(widthRes);
  47. int heightRes = (int) (imageSize.getDpiVertical() * 10);
  48. objectAreaInfo.setHeightRes(heightRes);
  49. imageObjectInfo.setInputStream(ccitt.createInputStream());
  50. return imageObjectInfo;
  51. }
  52. /** {@inheritDoc} */
  53. protected AFPDataObjectInfo createDataObjectInfo() {
  54. return new AFPImageObjectInfo();
  55. }
  56. /** {@inheritDoc} */
  57. public int getPriority() {
  58. return 400;
  59. }
  60. /** {@inheritDoc} */
  61. public Class[] getSupportedImageClasses() {
  62. return CLASSES;
  63. }
  64. /** {@inheritDoc} */
  65. public ImageFlavor[] getSupportedImageFlavors() {
  66. return FLAVORS;
  67. }
  68. }