[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Apple II graphics conversion



Apple Game Server 3.0 code has the conversion built in -- it was
necessary to make it callable from a standalone client in order to
test it efficiently.

The following is my test program for the HGR conversion -- it does the
following:

1. Load image from gif or jpg file
2. Convert image (performed by HGR/DHGR/DHGR2) classes
3. Convert apple screen image into rasterized B&W format
4. Save rasterized B&W BMP file
5. Call standalone Blargg display test program to show how image would
appear on actual screen

For what you're doing, you can cut out steps 3-5 and just write the
binary data to a file.  I meant to convert the Blargg code to java,
but never got around to it unfortunately.  It's pretty dense C code
for sure.  Beautiful and efficient, but oh so very dense.

The program is as follows:

/*
 * DHGRTest.java
 *
 * Created on June 23, 2006, 6:41 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

import ags.ui.graphics.Convert;
import ags.ui.graphics.HGRImage;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import javax.imageio.ImageIO;

public class HGRTest {
    // Path to image viewer utility, e.g. Blargg's apple_ntsc demo
program
    static String IMAGE_VIEWER_CMD = "/home/brobert/Documents/Personal/
blargg/dist/Debug/GNU-Linux-x86/blargg";

    public static void main(String[] args) throws IOException,
InterruptedException {
        HGRImage i = new HGRImage();
        String sourceFile =
          "/home/brobert/Pictures/CRW_1170_crop.jpg";
        i.readColorImage(sourceFile);
        //-----------------------------------
        // Write binary data to a file for transfer to an apple
        // This can be done through fishwings, ciderprsss or AGS.
//        File f = new File("/home/brobert/Desktop/yiq#062000");
//        OutputStream o = new FileOutputStream(f);
//        o.write(i.getAppleImage());
//        o.close();
        //-----------------------------------
        // Write out BW pattern to view
        // Put in same directory as source image
//        File outputDirectory = new File(sourceFile).getParentFile();
        // Put in tmp directory
        File outputDirectory = new File("/tmp");
        File testPattern = File.createTempFile("test_hgr_bw",".bmp",
outputDirectory);
        BufferedImage testbw = new BufferedImage(560, 192*2,
BufferedImage.TYPE_INT_RGB);
        Convert.convertHGRtoBWRaster(i.getAppleImage(), testbw);
        ImageIO.write(testbw, "bmp", testPattern);
        // Call the image viewer, passing the B&W image file path as a
parameter
        Runtime.getRuntime().exec(new String[]{IMAGE_VIEWER_CMD,
testPattern.getAbsolutePath()});

        // Tell java to remove BW file
        testPattern.deleteOnExit();
        // Give viewer app enough time to read file
        // otherwise program might exit and delte file too soon.
        Thread.sleep(1000);
    }
    /** Creates a new instance of DHGRTest */
    public HGRTest() {
    }

}

On Jun 16, 7:17 pm, Charles <thedangerman...@yahoo.com> wrote:
> Actually I'm looking for something that would go the opposite way -
> regular web graphics - jpg, gif, png to Apple ][ HGR screen. (no
> double hi-res or IIGS formats)
>
> I understand there is a .gif viewer for the Apple ][ is that correct?
> I've also heard it's pretty slow?
>
> Here is some info:
>
> http://www.vectronicsappleworld.com/appleii/gifviewer.html
>
> I know the Apple ][ won't display images perfectly, but I was
> wondering if anyone had any tips, Photoshop action, etc.
>
> My guess for best practices would be to use a modern photo editor to
> scale down the image, reduce the number of colors, convert to gif,
> etc.
>
> I'm wondering if there are any filters, cranking up the contrast,
> would help with the process?
>
> Any tips appreciated.