Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4357496

JPEG and GIF images be printed incompletely in Windows95/98.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.3.0
    • client-libs
    • 2d
    • x86
    • windows_95



      Name: el35337 Date: 07/28/2000


      When we attempt to print JPEG and GIF images in Windows95 or
      Windows98, the printed images become incomplete.
      There are two big problems.
      One is that the outline of letters(of the image) and curve lines
      becomes jagged.
      Another is that every image is printed two-tone(Black&White)
      with no greyscaling.

      The following is the test programs.
      But I can't send JPEG and GIF images.Please have JPEG or GIF
      image ready for this test.
      (This test program is Applet.)

      1. Applet program
      --------------------------------------------------------------
      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.*;
      import java.awt.print.*;

      public class Test extends JApplet
      {
      private Container pane;
      private JButton btn;
      private Image img;
      private Canv canv;

      public void init(){

      img = getImage(getDocumentBase(),"xxxxx.jpg"); //input JPG or GIF file name

      pane = getContentPane();
      pane.setLayout(new BorderLayout());

      btn = new JButton("Print");
      canv = new Canv(img);

      pane.add(btn,BorderLayout.NORTH);
      pane.add(canv,BorderLayout.CENTER);

      btn.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent evt){
      PrinterJob pj = PrinterJob.getPrinterJob();
      pj.setPrintable((Printable)canv);

      if(pj.printDialog()){
      try{
      pj.print();
      }catch(PrinterException pe){
      System.out.println(pe);
      }
      }
      }
      });
      }
      }

      class Canv extends Canvas implements Printable
      {
      Image img;

      Canv(Image img){
      this.img = img;
      }

      public void paint(Graphics g){
      g.drawImage(img,5,5,this);
      }

      /**
      *
      * Interface Printable print Method
      */
      public int print(Graphics g,PageFormat pf,int pageIndex)
      {
      if(pageIndex != 0){
      return NO_SUCH_PAGE;
      }

      //Graphics2D Cast
      Graphics2D g2 = (Graphics2D)g;

      //public abstract void translate(int x,int y)
      //Graphics2D
      g2.translate(pf.getImageableX(),pf.getImageableY());

      //g2 print
      paint(g2);
      return PAGE_EXISTS;
      }
      }
      -------------------------------------------------------------------

      2. HTML program
      --------------------------------------------------------------------
      <HTML>
      <BODY>
      <!--"CONVERTED_APPLET"-->
      <!-- CONVERTER VERSION 1.0 -->
      <CENTER>
      <BR>
      <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
      WIDTH = 500 HEIGHT = 300 codebase=
      "http://java.sun.com/products/plugin/1.2/jinstall-12-win32.cab#Version=1,2,0,0">
      <PARAM NAME = CODE VALUE = "DialogFromDayButton.class" >

      <PARAM NAME="type" VALUE="application/x-java-applet;version=1.2">
      <COMMENT>
      <EMBED type="application/x-java-applet;version=1.2" CODE = "Test.class"
      WIDTH = 500 HEIGHT = 300 pluginspage=
      "http://java.sun.com/products/plugin/1.2/plugin-install.html"><NOEMBED></COMMENT>

      </NOEMBED></EMBED>
      </OBJECT>
      <CENTER>

      <!--
      <APPLET CODE = "DialogFromButton.class" WIDTH = 500 HEIGHT = 400 >


      </APPLET>
      --------------------------------------------------------------------
      (Review ID: 106820)
      ======================================================================

            prr Philip Race
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: