mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-12-24 23:31:31 +00:00
Graphics for .FONT files
This commit is contained in:
parent
eaea2a9fc6
commit
491603247a
@ -1,5 +1,9 @@
|
||||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -11,13 +15,30 @@ public class FontFile extends AbstractFile
|
||||
{
|
||||
super (name, buffer);
|
||||
|
||||
image = new BufferedImage (8 * (7 + 4), 12 * (8 + 4), BufferedImage.TYPE_BYTE_GRAY);
|
||||
Graphics2D g2d = image.createGraphics ();
|
||||
g2d.setComposite (AlphaComposite.getInstance (AlphaComposite.SRC_OVER, (float) 1.0));
|
||||
|
||||
int ptr = 0;
|
||||
int x = 2;
|
||||
int y = 2;
|
||||
int count = 0;
|
||||
|
||||
while (ptr < buffer.length)
|
||||
{
|
||||
Character c = new Character (buffer, ptr);
|
||||
ptr += 8;
|
||||
characters.add (c);
|
||||
|
||||
g2d.drawImage (c.image, x, y, null);
|
||||
x += 7 + 4;
|
||||
if (++count % 8 == 0)
|
||||
{
|
||||
x = 2;
|
||||
y += 8 + 4;
|
||||
}
|
||||
}
|
||||
g2d.dispose ();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -48,9 +69,15 @@ public class FontFile extends AbstractFile
|
||||
class Character
|
||||
{
|
||||
String[] lines = new String[8];
|
||||
private final BufferedImage image;
|
||||
|
||||
public Character (byte[] buffer, int ptr)
|
||||
{
|
||||
// draw the image
|
||||
image = new BufferedImage (7, 8, BufferedImage.TYPE_BYTE_GRAY);
|
||||
DataBuffer dataBuffer = image.getRaster ().getDataBuffer ();
|
||||
int element = 0;
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int b = buffer[ptr + i] & 0xFF;
|
||||
@ -59,6 +86,8 @@ public class FontFile extends AbstractFile
|
||||
s = s.replace ('0', ' ');
|
||||
s = s.replace ('1', 'O');
|
||||
s = new StringBuilder (s).reverse ().toString ();
|
||||
for (byte ch : s.getBytes ())
|
||||
dataBuffer.setElem (element++, ch == ' ' ? 0 : 255);
|
||||
lines[i] = s;
|
||||
}
|
||||
}
|
||||
|
@ -64,12 +64,10 @@ public class ShapeTable extends AbstractFile
|
||||
int y = 10;
|
||||
int count = 0;
|
||||
Graphics2D g2d = image.createGraphics ();
|
||||
g2d.setComposite (AlphaComposite.getInstance (AlphaComposite.SRC_OVER, (float) 1.0));
|
||||
|
||||
for (Shape shape : shapes)
|
||||
{
|
||||
// System.out.println (shape);
|
||||
g2d.setComposite (
|
||||
AlphaComposite.getInstance (AlphaComposite.SRC_OVER, (float) 1.0));
|
||||
g2d.drawImage (shape.image, x, y, null);
|
||||
x += maxWidth + 5;
|
||||
if (++count % cols == 0)
|
||||
|
@ -260,6 +260,9 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
||||
&& reportedLength == 0x14FA)
|
||||
return true;
|
||||
|
||||
// if (name.endsWith (".PAC"))
|
||||
// return true;
|
||||
|
||||
if (name.equals ("BBROS LOGO SCRUNCHED") && reportedLength == 0x0FED)
|
||||
return true;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user