Class GraphicsFileFilter
- java.lang.Object
-
- com.webcodepro.applecommander.storage.filters.GraphicsFileFilter
-
- All Implemented Interfaces:
FileFilter
public class GraphicsFileFilter extends java.lang.Object implements FileFilter
Filter the given file as if it were a graphics image.Address for Apple2 HGR/DHR address is calculated from an observation of a pattern:
line number bits: 87654321
87 are multiplied by 0x0028
65 are multiplied by 0x0100
4 is multiplied by 0x0080
321 are multiplied by 0x0400HGR bit values ignore the high bit, as that switches the "palette", and for B&W mode, the bit does nothing. The other 7 bits simply toggle the pixel on or off. Double hires does not follow this - it uses a real 4 bit value, but the high bit is still ignored for graphics (hence, the 560 instead of 640 resolution).
SHR has been implemented in "16 color" mode as well as 3200 color mode. Note that 16 color mode is really 16 palettes of 16 colors while 3200 color mode is 200 palettes of 16 colors (one palette per line).
NOTE: The design is feeling kludgy. There are 6 distinct variations - possibly a subclass is needed to interpret the various graphic image or some such redesign.
Date created: Nov 3, 2002 12:06:36 PM
-
-
Field Summary
Fields Modifier and Type Field Description static intMODE_DHR_BLACK_AND_WHITEstatic intMODE_DHR_COLORstatic intMODE_HGR_BLACK_AND_WHITEstatic intMODE_HGR_COLORstatic intMODE_QUICKDRAW2_ICONstatic intMODE_SHR_16static intMODE_SHR_3200
-
Constructor Summary
Constructors Constructor Description GraphicsFileFilter()Constructor for GraphicsFileFilter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected AppleImage[]buildQuickDraw2IconAndMask(byte[] filedata, int offset)Each icon is composed of two images - one an icon and the other is the mask.protected AppleImagebuildQuickDraw2IconOrMask(byte[] filedata, boolean isColor, int height, int width, int offset)Build an image of an individual icon or its mask.AppleImage[]buildQuickDraw2Icons(FileEntry fileEntry)Construct a series of icons based on the QuickDraw II Icon file format.voidcopyImage(AppleImage destImage, AppleImage srcImage, int xStart, int yStart)Copy an image from the source image to the destination image.byte[]filter(FileEntry fileEntry)Filter the file data and produce an image.java.lang.StringgetExtension()Get the format name.static java.lang.String[]getFileExtensions()Give file extensions.java.lang.StringgetSuggestedFileName(FileEntry fileEntry)Give suggested file name.static booleanisCodecAvailable()Indicate if a codec is available (assist with interface requirements).booleanisDoubleHiresBlackAndWhiteMode()Indicates if this is configured for double hires black & white mode.booleanisDoubleHiresColorMode()Indicates if this is configured for double hires color mode.booleanisDoubleHiresMode()Indicates if this is a double hires mode.booleanisHiresBlackAndWhiteMode()Indicates if this is configured for hires black & white mode.booleanisHiresColorMode()Indicates if this is configured for hires color mode.booleanisHiresMode()Indicates if this is a hires mode.booleanisQuickDraw2Icon()Indicates if this is a QuickDraw II Icon.booleanisSuperHires16Mode()Indicates if this is configured for super hires 16 color mode.booleanisSuperHires3200Mode()Indicates if this is configured for super hires 3200 color mode.booleanisSuperHiresMode()Indicates if this is a super-hires mode.protected voidprocessDoubleHiresBlackAndWhiteLine(byte[] lineData1, byte[] lineData2, AppleImage image, int y)Given a specific line in the image, process it in double hires black and white mode.protected voidprocessDoubleHiresColorLine(byte[] lineData1, byte[] lineData2, AppleImage image, int y)Given a specific line in the image, process it in double hires color mode.protected voidprocessHiresBlackAndWhiteLine(byte[] lineData, AppleImage image, int y)Given a specific line in the image, process it in hires black and white mode.protected voidprocessHiresColorLine(byte[] lineData, AppleImage image, int y)Given a specific line in the image, process it in hires color mode.protected voidprocessSuperHiresLine(byte[] lineData, AppleImage image, int y, byte scb, byte[] pallettes)Given a specific line in the image, process it in super hires color mode.voidsetExtension(java.lang.String extension)Set the format name.voidsetMode(int mode)Set the color mode.
-
-
-
Field Detail
-
MODE_HGR_BLACK_AND_WHITE
public static final int MODE_HGR_BLACK_AND_WHITE
- See Also:
- Constant Field Values
-
MODE_HGR_COLOR
public static final int MODE_HGR_COLOR
- See Also:
- Constant Field Values
-
MODE_DHR_BLACK_AND_WHITE
public static final int MODE_DHR_BLACK_AND_WHITE
- See Also:
- Constant Field Values
-
MODE_DHR_COLOR
public static final int MODE_DHR_COLOR
- See Also:
- Constant Field Values
-
MODE_SHR_16
public static final int MODE_SHR_16
- See Also:
- Constant Field Values
-
MODE_SHR_3200
public static final int MODE_SHR_3200
- See Also:
- Constant Field Values
-
MODE_QUICKDRAW2_ICON
public static final int MODE_QUICKDRAW2_ICON
- See Also:
- Constant Field Values
-
-
Method Detail
-
isCodecAvailable
public static boolean isCodecAvailable()
Indicate if a codec is available (assist with interface requirements).
-
filter
public byte[] filter(FileEntry fileEntry)
Filter the file data and produce an image.- Specified by:
filterin interfaceFileFilter- See Also:
FileFilter.filter(FileEntry)
-
processHiresBlackAndWhiteLine
protected void processHiresBlackAndWhiteLine(byte[] lineData, AppleImage image, int y)Given a specific line in the image, process it in hires black and white mode.
-
processHiresColorLine
protected void processHiresColorLine(byte[] lineData, AppleImage image, int y)Given a specific line in the image, process it in hires color mode. HGR color is two bits to determine color - essentially resolution is 140 horizontally, but it indicates the color for two pixels.The names of pixels is a bit confusion - pixel0 is really the left-most pixel (not the low-value bit). To alleviate my bad naming, here is a color table to assist:
Color Bits RGB ======= ==== ======== Black1 000 0x000000 Green 001 0x00ff00 Violet 010 0xff00ff White1 011 0xffffff Black2 100 0x000000 Orange 101 0xff8000 Blue 110 0x0000ff White2 111 0xffffff
Remember: bits are listed as "highbit", "pixel0", "pixel1"!
-
processDoubleHiresBlackAndWhiteLine
protected void processDoubleHiresBlackAndWhiteLine(byte[] lineData1, byte[] lineData2, AppleImage image, int y)Given a specific line in the image, process it in double hires black and white mode.
-
processDoubleHiresColorLine
protected void processDoubleHiresColorLine(byte[] lineData1, byte[] lineData2, AppleImage image, int y)Given a specific line in the image, process it in double hires color mode. Treat image as 140x192 mode.
-
processSuperHiresLine
protected void processSuperHiresLine(byte[] lineData, AppleImage image, int y, byte scb, byte[] pallettes)Given a specific line in the image, process it in super hires color mode.The color map varies depending upon the SCB value(s) and the pallettes stored with the image. The SCB does not apple to 3200 SHR mode!
-
buildQuickDraw2Icons
public AppleImage[] buildQuickDraw2Icons(FileEntry fileEntry)
Construct a series of icons based on the QuickDraw II Icon file format. In ProDOS, this is the ICN ($Ca) file format.- See Also:
- File Types
-
buildQuickDraw2IconAndMask
protected AppleImage[] buildQuickDraw2IconAndMask(byte[] filedata, int offset)
Each icon is composed of two images - one an icon and the other is the mask.
-
buildQuickDraw2IconOrMask
protected AppleImage buildQuickDraw2IconOrMask(byte[] filedata, boolean isColor, int height, int width, int offset)
Build an image of an individual icon or its mask.
-
copyImage
public void copyImage(AppleImage destImage, AppleImage srcImage, int xStart, int yStart)
Copy an image from the source image to the destination image. This isn't optimal, nor can it be - we're hiding the actual image implementation, after all. Initially written to handle Apple IIGS Toolbox Icon files.
-
getFileExtensions
public static java.lang.String[] getFileExtensions()
Give file extensions.
-
getSuggestedFileName
public java.lang.String getSuggestedFileName(FileEntry fileEntry)
Give suggested file name.- Specified by:
getSuggestedFileNamein interfaceFileFilter
-
setExtension
public void setExtension(java.lang.String extension)
Set the format name.
-
getExtension
public java.lang.String getExtension()
Get the format name.
-
setMode
public void setMode(int mode)
Set the color mode.
-
isHiresBlackAndWhiteMode
public boolean isHiresBlackAndWhiteMode()
Indicates if this is configured for hires black & white mode.
-
isHiresColorMode
public boolean isHiresColorMode()
Indicates if this is configured for hires color mode.
-
isDoubleHiresBlackAndWhiteMode
public boolean isDoubleHiresBlackAndWhiteMode()
Indicates if this is configured for double hires black & white mode.
-
isDoubleHiresColorMode
public boolean isDoubleHiresColorMode()
Indicates if this is configured for double hires color mode.
-
isSuperHires16Mode
public boolean isSuperHires16Mode()
Indicates if this is configured for super hires 16 color mode.
-
isSuperHires3200Mode
public boolean isSuperHires3200Mode()
Indicates if this is configured for super hires 3200 color mode.
-
isHiresMode
public boolean isHiresMode()
Indicates if this is a hires mode.
-
isDoubleHiresMode
public boolean isDoubleHiresMode()
Indicates if this is a double hires mode.
-
isSuperHiresMode
public boolean isSuperHiresMode()
Indicates if this is a super-hires mode.
-
isQuickDraw2Icon
public boolean isQuickDraw2Icon()
Indicates if this is a QuickDraw II Icon.
-
-