呵呵,应大家的要求,做了个 A to Z, a to Z, 1 to 9, SPACE 共 63 个字符的程序,代码太长,分两次发。import java.util.HashMap; import java.util.Map;public class LetterMatrix {
public static void main(String[] args) { LetterMatrix matrix = new LetterMatrix(); matrix.printString("Hello World"); }
private static Map<Character, int[]> letterMapping = null; public final static int MATRIX_ARRAY = 16; private final static int[] SPACE = new int[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static { init(); }
public void printString(String str) { if(!str.matches("[0-9A-Za-z ]*")) { throw new IllegalArgumentException("ONLY accept A to Z, a to z, 0 to 9 and space"); } char[] chars = str.toCharArray(); printCharArray(chars); }
private void printCharArray(char[] chars) { int allchars[][] = new int[chars.length][]; for(int i = 0; i < chars.length; i++) { allchars[i] = letterMapping.get(chars[i]); }
for(int i = 0; i < MATRIX_ARRAY; i++) { for(int j = 0, k = chars.length; j < k; j++) { int[] letter = allchars[j]; int len = letter == SPACE ? 8 : 16; for(int m = 0; m < len; m++ ) { System.out.print((letter[i] & (0x8000 >> m)) == 0 ? " " : "#"); } } System.out.println(); } }
private static void init() { letterMapping = new HashMap<Character, int[]>(); letterMapping.put('A', new int[]{0x0000,0x0000,0x0000,0x01C0,0x03C0,0x02E0,0x0660,0x0C70, 0x0C70,0x0FF8,0x1838,0x1018,0x301C,0xFC3F,0x0000,0x0000}); letterMapping.put('B', new int[]{0x0000,0x0000,0x0000,0x7FF8,0x181C,0x181E,0x181C,0x1FF8, 0x1FFC,0x180E,0x180E,0x180E,0x181E,0xFFF8,0x0000,0x0000}); letterMapping.put('C', new int[]{0x0000,0x0000,0x0000,0x07FE,0x1C06,0x3802,0x7000,0x7000, 0x7000,0x7000,0x7002,0x3802,0x1C0C,0x07F8,0x0000,0x0000}); letterMapping.put('D', new int[]{0x0000,0x0000,0x0000,0x7FF0,0x183C,0x180E,0x180E,0x180E, 0x180F,0x180E,0x180E,0x180C,0x1838,0x7FE0,0x0000,0x0000}); letterMapping.put('E', new int[]{0x0000,0x0000,0x0000,0x7FFC,0x1C0E,0x1C02,0x1C10,0x1FF0, 0x1FF0,0x1C10,0x1C00,0x1C02,0x1C06,0x7FFC,0x0000,0x0000}); letterMapping.put('F', new int[]{0x0000,0x0000,0x0000,0x7FFE,0x1C06,0x1C00,0x1C18,0x1C38, 0x1FF8,0x1C18,0x1C00,0x1C00,0x1C00,0x7F00,0x0000,0x0000}); letterMapping.put('G', new int[]{0x0000,0x0000,0x0000,0x07F8,0x1C1C,0x380C,0x7000,0x7000, 0x7000,0x703F,0x701C,0x381C,0x1C1C,0x0FFC,0x0000,0x0000}); letterMapping.put('H', new int[]{0x0000,0x0000,0x0000,0x7C3F,0x381C,0x381C,0x381C,0x381C, 0x3FFC,0x381C,0x381C,0x381C,0x381C,0xFE3F,0x0000,0x0000}); letterMapping.put('I', new int[]{0x0000,0x0000,0x0000,0x1FF8,0x01C0,0x01C0,0x01C0,0x01C0, 0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x1FFC,0x0000,0x0000}); letterMapping.put('J', new int[]{0x0000,0x0000,0x0000,0x07FE,0x0070,0x0070,0x0070,0x0070, 0x0070,0x0070,0x0070,0x0070,0x0070,0x3070,0x78E0,0x3F80}); letterMapping.put('K', new int[]{0x0000,0x0000,0x0000,0x7E3E,0x1830,0x1860,0x19C0,0x1B80, 0x1FC0,0x18E0,0x1870,0x1838,0x181C,0x7E3F,0x0000,0x0000}); letterMapping.put('L', new int[]{0x0000,0x0000,0x0000,0x7E00,0x1C00,0x1C00,0x1C00,0x1C00, 0x1C00,0x1C00,0x1C00,0x1C03,0x1C06,0x7FFE,0x0000,0x0000}); letterMapping.put('M', new int[]{0x0000,0x0000,0x0000,0x781F,0x381E,0x3C3E,0x3C3E,0x2C6E, 0x2E6E,0x26CE,0x27CE,0x238E,0x238E,0xFB3F,0x0000,0x0000}); letterMapping.put('N', new int[]{0x0000,0x0000,0x0000,0x781F,0x3C04,0x3E04,0x3704,0x3384, 0x31C4,0x30E4,0x3034,0x301C,0x300C,0xFC04,0x0000,0x0000}); letterMapping.put('O', new int[]{0x0000,0x0000,0x0000,0x0FF0,0x1C1C,0x380E,0x700E,0x7007, 0x7007,0x7007,0x300E,0x380E,0x1C1C,0x07F0,0x0000,0x0000}); letterMapping.put('P', new int[]{0x0000,0x0000,0x0000,0x7FF8,0x1C0E,0x1C0E,0x1C0E,0x1C1C, 0x1FF8,0x1C00,0x1C00,0x1C00,0x1C00,0x7F00,0x0000,0x0000}); letterMapping.put('Q', new int[]{0x0000,0x0000,0x0000,0x0FF0,0x1C1C,0x380E,0x700E,0x7007, 0x7007,0x700F,0x738E,0x39CE,0x1C7C,0x07F0,0x003E,0x000C}); letterMapping.put('R', new int[]{0x0000,0x0000,0x0000,0x3FF8,0x1C1C,0x1C0E,0x1C0C,0x1C78, 0x1FE0,0x1CE0,0x1C70,0x1C38,0x1C1C,0x7E0F,0x0000,0x0000}); letterMapping.put('S', new int[]{0x0000,0x0000,0x0000,0x0FFC,0x301C,0x3004,0x3800,0x1F80, 0x03F0,0x003C,0x200E,0x200E,0x380C,0x3FF8,0x0000,0x0000}); letterMapping.put('T', new int[]{0x0000,0x0000,0x0000,0x3FFE,0x61C6,0x41C2,0x01C0,0x01C0, 0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x0FF0,0x0000,0x0000}); letterMapping.put('U', new int[]{0x0000,0x0000,0x0000,0x7C1E,0x3804,0x3804,0x3804,0x3804, 0x3804,0x3804,0x3804,0x3804,0x1C18,0x0FF0,0x0000,0x0000}); letterMapping.put('V', new int[]{0x0000,0x0000,0x0000,0x7C1E,0x180C,0x1C18,0x0C10,0x0E30, 0x0E20,0x0760,0x0740,0x03C0,0x0380,0x0180,0x0000,0x0000}); letterMapping.put('W', new int[]{0x0000,0x0000,0x0000,0x7BCF,0x31C6,0x31C4,0x39CC,0x3BEC, 0x1BF8,0x1F78,0x1E78,0x0E70,0x0C30,0x0C20,0x0000,0x0000}); letterMapping.put('X', new int[]{0x0000,0x0000,0x0000,0x3E3E,0x0C18,0x0E30,0x0760,0x03C0, 0x01C0,0x03E0,0x0670,0x0C38,0x081C,0x7C3F,0x0000,0x0000}); letterMapping.put('Y', new int[]{0x0000,0x0000,0x0000,0x7E3E,0x1C08,0x0C10,0x0E30,0x0760, 0x03C0,0x01C0,0x01C0,0x01C0,0x01C0,0x0FF0,0x0000,0x0000}); letterMapping.put('Z', new int[]{0x0000,0x0000,0x0000,0x1FFE,0x381C,0x2038,0x0070,0x00E0, 0x01C0,0x0380,0x0600,0x0C06,0x380C,0x7FFC,0x0000,0x0000});未完,待续
接上一楼
letterMapping.put('a', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x07E0,0x1E78, 0x381C,0x07FC,0x1E1C,0x301C,0x303D,0x1FCE,0x0000,0x0000}); letterMapping.put('b', new int[]{0x0000,0x0000,0x0800,0x7800,0x1800,0x1800,0x19F0,0x1FFC, 0x1C0C,0x180E,0x180E,0x180E,0x181C,0x1FF0,0x0000,0x0000}); letterMapping.put('c', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E0,0x0F38, 0x181C,0x3800,0x3800,0x3804,0x1C0C,0x0FF8,0x0000,0x0000}); letterMapping.put('d', new int[]{0x0000,0x0000,0x0000,0x003C,0x001C,0x001C,0x03DC,0x0E7C, 0x381C,0x381C,0x381C,0x381C,0x1C3C,0x0FCE,0x0000,0x0000}); letterMapping.put('e', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E0,0x0F78, 0x180C,0x3FFE,0x3FFC,0x3800,0x1C0C,0x07F0,0x0000,0x0000}); letterMapping.put('f', new int[]{0x0000,0x0000,0x0000,0x01FE,0x0307,0x0700,0x3FF8,0x3FF8, 0x0700,0x0700,0x0700,0x0700,0x0700,0x3FF0,0x0000,0x0000}); letterMapping.put('g', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03EE,0x0E7E, 0x1818,0x1818,0x0FF0,0x1980,0x1FFC,0x383E,0x300E,0x1FF8}); letterMapping.put('h', new int[]{0x0000,0x0000,0x0800,0x7800,0x1800,0x1800,0x19F0,0x1FF8, 0x181C,0x181C,0x181C,0x181C,0x181C,0x7E3F,0x0000,0x0000}); letterMapping.put('i', new int[]{0x0000,0x0000,0x0000,0x01C0,0x01C0,0x0000,0x0FC0,0x0FC0, 0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x1FF8,0x0000,0x0000}); letterMapping.put('j', new int[]{0x0000,0x0000,0x0000,0x0038,0x0038,0x0000,0x01F8,0x01F8, 0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x1830,0x1FE0}); letterMapping.put('k', new int[]{0x0000,0x0000,0x0800,0x3800,0x1800,0x1800,0x187C,0x187C, 0x18E0,0x1B80,0x1EE0,0x1870,0x1838,0x7E3F,0x0000,0x0000}); letterMapping.put('l', new int[]{0x0000,0x0000,0x0080,0x0FC0,0x01C0,0x01C0,0x01C0,0x01C0, 0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x1FFC,0x0000,0x0000}); letterMapping.put('m', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x771C,0x7FFE, 0x31C6,0x31C6,0x31C6,0x31C6,0x31C6,0xFBEF,0x0000,0x0000}); letterMapping.put('n', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x79F0,0x7FF8, 0x181C,0x181C,0x181C,0x181C,0x181C,0x7E3F,0x0000,0x0000}); letterMapping.put('o', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E0,0x0F78, 0x380C,0x300E,0x700E,0x380E,0x181C,0x0FF0,0x0000,0x0000}); letterMapping.put('p', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x79E0,0x7FFC, 0x180E,0x180E,0x180E,0x180E,0x1C1C,0x1FF8,0x1800,0x7E00}); letterMapping.put('q', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03C0,0x1E7C, 0x381C,0x381C,0x301C,0x381C,0x181C,0x0FFC,0x001C,0x003E}); letterMapping.put('r', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7E3C,0x7EFE, 0x0F04,0x0E00,0x0E00,0x0E00,0x0E00,0x7FE0,0x0000,0x0000}); letterMapping.put('s', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E8,0x0E7C, 0x180C,0x0F80,0x03F8,0x101C,0x180C,0x1FF8,0x0000,0x0000}); letterMapping.put('t', new int[]{0x0000,0x0000,0x0000,0x0000,0x0100,0x0300,0x3FF8,0x3FF8, 0x0300,0x0300,0x0300,0x0304,0x030C,0x01F8,0x0000,0x0000}); letterMapping.put('u', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x783C,0x783C, 0x181C,0x181C,0x181C,0x181C,0x183C,0x0FDE,0x0000,0x0000}); letterMapping.put('v', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3E1E,0x3E1E, 0x0C18,0x0E30,0x0720,0x0360,0x03C0,0x0180,0x0000,0x0000}); letterMapping.put('w', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7BCF,0x7BCF, 0x39CC,0x39CC,0x1BE8,0x1E78,0x0E70,0x0C30,0x0000,0x0000}); letterMapping.put('x', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3E3C,0x3E3C, 0x0720,0x03C0,0x01C0,0x0670,0x0C38,0x7E7E,0x0000,0x0000}); letterMapping.put('y', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3E3E,0x3E3E, 0x0E18,0x0630,0x0360,0x03E0,0x01C0,0x0180,0x1900,0x3E00}); letterMapping.put('z', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1FF8,0x3FF8, 0x3070,0x01C0,0x0380,0x0704,0x1C0C,0x3FFC,0x0000,0x0000});
letterMapping.put('0', new int[]{0x0000,0x0000,0x0000,0x07F0,0x1C18,0x381C,0x380E,0x380E, 0x780E,0x380E,0x380E,0x381C,0x1C18,0x07F0,0x0000,0x0000}); letterMapping.put('1', new int[]{0x0000,0x0000,0x0000,0x01C0,0x0FC0,0x01C0,0x01C0,0x01C0, 0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x0FFC,0x0000,0x0000}); letterMapping.put('2', new int[]{0x0000,0x0000,0x0000,0x0FF8,0x181C,0x381C,0x181C,0x0038, 0x0070,0x01C0,0x0700,0x0C06,0x3FFC,0x3FFC,0x0000,0x0000}); letterMapping.put('3', new int[]{0x0000,0x0000,0x0000,0x0FF0,0x3838,0x381C,0x0038,0x03F0, 0x03F0,0x001C,0x000E,0x381C,0x381C,0x0FF0,0x0000,0x0000}); letterMapping.put('4', new int[]{0x0000,0x0000,0x0000,0x0030,0x00F0,0x01F0,0x0370,0x0C70, 0x1870,0x3070,0x3FFE,0x0070,0x0070,0x03FE,0x0000,0x0000}); letterMapping.put('5', new int[]{0x0000,0x0000,0x0000,0x1FFC,0x1800,0x1800,0x18C0,0x1FF8, 0x181C,0x001E,0x100E,0x381C,0x3818,0x0FF0,0x0000,0x0000}); letterMapping.put('6', new int[]{0x0000,0x0000,0x0000,0x07F8,0x0C3C,0x1808,0x3800,0x3FF8, 0x7C1C,0x780E,0x380E,0x380E,0x1C1C,0x07F0,0x0000,0x0000}); letterMapping.put('7', new int[]{0x0000,0x0000,0x0000,0x1FFE,0x3C0C,0x3018,0x0030,0x0060, 0x00C0,0x01C0,0x0380,0x0380,0x0380,0x0380,0x0000,0x0000}); letterMapping.put('8', new int[]{0x0000,0x0000,0x0000,0x0FF8,0x380C,0x300E,0x3C0C,0x1FF8, 0x0FF0,0x383C,0x300E,0x700E,0x380C,0x0FF0,0x0000,0x0000}); letterMapping.put('9', new int[]{0x0000,0x0000,0x0000,0x0FF0,0x3818,0x300C,0x700E,0x300E, 0x383E,0x1FEE,0x001C,0x1818,0x3C30,0x1FE0,0x0000,0x0000});
System.out.println("*");
自己拼去,多尝试几次就好了
public class Love{
public static void main(String[] args){
System.out.println("***"+" "+"***"+" "+"*"+" "+"*");
System.out.println(" "+"*"+" "+"*"+" "+"***"+" "+"*"+" "+"*"+" "+"***"+" "+"*"+" "+"*"+" "+"***"+" "+"*"+" "+"*");
System.out.println(" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*");
System.out.println(" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*****"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*");
System.out.println(" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*");
System.out.println("***"+" "+"***"+" "+"***"+" "+"*"+" "+"*****"+" "+"*"+" "+"***"+" "+"***");
}
}
awt里面有的。
先获得字母的区域,然后用*填充那个区域。
import java.util.List;public class Test { public static void main(String[] args) {
int[] LETTER_I = {0x0000,0x0000,0x0000,0x1FF8,0x01C0,0x01C0,0x01C0,0x01C0,
0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x1FFC,0x0000,0x0000};
int[] LETTER_l = {0x0000,0x0000,0x0080,0x0FC0,0x01C0,0x01C0,0x01C0,0x01C0,
0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x1FFC,0x0000,0x0000};
int[] LETTER_o = {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E0,0x0F78,
0x380C,0x300E,0x700E,0x380E,0x181C,0x0FF0,0x0000,0x0000};
int[] LETTER_v = {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3E1E,0x3E1E,
0x0C18,0x0E30,0x0720,0x0360,0x03C0,0x0180,0x0000,0x0000};
int[] LETTER_e = {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E0,0x0F78,
0x180C,0x3FFE,0x3FFC,0x3800,0x1C0C,0x07F0,0x0000,0x0000};
int[] LETTER_y = {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3E3E,0x3E3E,
0x0E18,0x0630,0x0360,0x03E0,0x01C0,0x0180,0x1900,0x3E00};
int[] LETTER_u = {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x783C,0x783C,
0x181C,0x181C,0x181C,0x181C,0x183C,0x0FDE,0x0000,0x0000};
int[] SPACE = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
List<int[]> list = new ArrayList<int[]>();
list.add(LETTER_I);
list.add(SPACE);
list.add(LETTER_l);
list.add(LETTER_o);
list.add(LETTER_v);
list.add(LETTER_e);
list.add(SPACE);
list.add(LETTER_y);
list.add(LETTER_o);
list.add(LETTER_u);
for(int i = 0; i < 16; i++) {
for(int j = 0, k = list.size(); j < k; j++) {
int[] tmp = list.get(j);
int len = tmp == SPACE ? 8 : 16;
int[] letter = tmp.clone();
for(int m = 0; m < len; m++ ) {
System.out.print(((letter[i] <<= 1) & 0x8000) == 0 ? " " : "#");
}
}
System.out.println();
}
}
}输出效果:
#
########## ######
### ###
### ###
### ### ##### ##### #### ##### ##### ##### ##### #### ####
### ### #### #### ##### #### #### #### ##### ##### #### #### #### ####
### ### ### ## ## ## ## ## ### ## ### ## ## ###
### ### ## ### ### ## ############# ## ## ## ### ## ###
### ### ### ### ### # ############ ## ## ### ### ## ###
### ### ### ### ## ## ### ##### ### ### ## ###
### ### ## ### #### ### ## ### ## ### ## ####
########### ########### ######## ## ####### ## ######## ###### ####
import java.util.Map;public class LetterMatrix {
public static void main(String[] args) {
LetterMatrix matrix = new LetterMatrix();
matrix.printString("Hello World");
}
private static Map<Character, int[]> letterMapping = null;
public final static int MATRIX_ARRAY = 16;
private final static int[] SPACE = new int[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static {
init();
}
public void printString(String str) {
if(!str.matches("[0-9A-Za-z ]*")) {
throw new IllegalArgumentException("ONLY accept A to Z, a to z, 0 to 9 and space");
}
char[] chars = str.toCharArray();
printCharArray(chars);
}
private void printCharArray(char[] chars) {
int allchars[][] = new int[chars.length][];
for(int i = 0; i < chars.length; i++) {
allchars[i] = letterMapping.get(chars[i]);
}
for(int i = 0; i < MATRIX_ARRAY; i++) {
for(int j = 0, k = chars.length; j < k; j++) {
int[] letter = allchars[j];
int len = letter == SPACE ? 8 : 16;
for(int m = 0; m < len; m++ ) {
System.out.print((letter[i] & (0x8000 >> m)) == 0 ? " " : "#");
}
}
System.out.println();
}
}
private static void init() {
letterMapping = new HashMap<Character, int[]>();
letterMapping.put('A', new int[]{0x0000,0x0000,0x0000,0x01C0,0x03C0,0x02E0,0x0660,0x0C70,
0x0C70,0x0FF8,0x1838,0x1018,0x301C,0xFC3F,0x0000,0x0000});
letterMapping.put('B', new int[]{0x0000,0x0000,0x0000,0x7FF8,0x181C,0x181E,0x181C,0x1FF8,
0x1FFC,0x180E,0x180E,0x180E,0x181E,0xFFF8,0x0000,0x0000});
letterMapping.put('C', new int[]{0x0000,0x0000,0x0000,0x07FE,0x1C06,0x3802,0x7000,0x7000,
0x7000,0x7000,0x7002,0x3802,0x1C0C,0x07F8,0x0000,0x0000});
letterMapping.put('D', new int[]{0x0000,0x0000,0x0000,0x7FF0,0x183C,0x180E,0x180E,0x180E,
0x180F,0x180E,0x180E,0x180C,0x1838,0x7FE0,0x0000,0x0000});
letterMapping.put('E', new int[]{0x0000,0x0000,0x0000,0x7FFC,0x1C0E,0x1C02,0x1C10,0x1FF0,
0x1FF0,0x1C10,0x1C00,0x1C02,0x1C06,0x7FFC,0x0000,0x0000});
letterMapping.put('F', new int[]{0x0000,0x0000,0x0000,0x7FFE,0x1C06,0x1C00,0x1C18,0x1C38,
0x1FF8,0x1C18,0x1C00,0x1C00,0x1C00,0x7F00,0x0000,0x0000});
letterMapping.put('G', new int[]{0x0000,0x0000,0x0000,0x07F8,0x1C1C,0x380C,0x7000,0x7000,
0x7000,0x703F,0x701C,0x381C,0x1C1C,0x0FFC,0x0000,0x0000});
letterMapping.put('H', new int[]{0x0000,0x0000,0x0000,0x7C3F,0x381C,0x381C,0x381C,0x381C,
0x3FFC,0x381C,0x381C,0x381C,0x381C,0xFE3F,0x0000,0x0000});
letterMapping.put('I', new int[]{0x0000,0x0000,0x0000,0x1FF8,0x01C0,0x01C0,0x01C0,0x01C0,
0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x1FFC,0x0000,0x0000});
letterMapping.put('J', new int[]{0x0000,0x0000,0x0000,0x07FE,0x0070,0x0070,0x0070,0x0070,
0x0070,0x0070,0x0070,0x0070,0x0070,0x3070,0x78E0,0x3F80});
letterMapping.put('K', new int[]{0x0000,0x0000,0x0000,0x7E3E,0x1830,0x1860,0x19C0,0x1B80,
0x1FC0,0x18E0,0x1870,0x1838,0x181C,0x7E3F,0x0000,0x0000});
letterMapping.put('L', new int[]{0x0000,0x0000,0x0000,0x7E00,0x1C00,0x1C00,0x1C00,0x1C00,
0x1C00,0x1C00,0x1C00,0x1C03,0x1C06,0x7FFE,0x0000,0x0000});
letterMapping.put('M', new int[]{0x0000,0x0000,0x0000,0x781F,0x381E,0x3C3E,0x3C3E,0x2C6E,
0x2E6E,0x26CE,0x27CE,0x238E,0x238E,0xFB3F,0x0000,0x0000});
letterMapping.put('N', new int[]{0x0000,0x0000,0x0000,0x781F,0x3C04,0x3E04,0x3704,0x3384,
0x31C4,0x30E4,0x3034,0x301C,0x300C,0xFC04,0x0000,0x0000});
letterMapping.put('O', new int[]{0x0000,0x0000,0x0000,0x0FF0,0x1C1C,0x380E,0x700E,0x7007,
0x7007,0x7007,0x300E,0x380E,0x1C1C,0x07F0,0x0000,0x0000});
letterMapping.put('P', new int[]{0x0000,0x0000,0x0000,0x7FF8,0x1C0E,0x1C0E,0x1C0E,0x1C1C,
0x1FF8,0x1C00,0x1C00,0x1C00,0x1C00,0x7F00,0x0000,0x0000});
letterMapping.put('Q', new int[]{0x0000,0x0000,0x0000,0x0FF0,0x1C1C,0x380E,0x700E,0x7007,
0x7007,0x700F,0x738E,0x39CE,0x1C7C,0x07F0,0x003E,0x000C});
letterMapping.put('R', new int[]{0x0000,0x0000,0x0000,0x3FF8,0x1C1C,0x1C0E,0x1C0C,0x1C78,
0x1FE0,0x1CE0,0x1C70,0x1C38,0x1C1C,0x7E0F,0x0000,0x0000});
letterMapping.put('S', new int[]{0x0000,0x0000,0x0000,0x0FFC,0x301C,0x3004,0x3800,0x1F80,
0x03F0,0x003C,0x200E,0x200E,0x380C,0x3FF8,0x0000,0x0000});
letterMapping.put('T', new int[]{0x0000,0x0000,0x0000,0x3FFE,0x61C6,0x41C2,0x01C0,0x01C0,
0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x0FF0,0x0000,0x0000});
letterMapping.put('U', new int[]{0x0000,0x0000,0x0000,0x7C1E,0x3804,0x3804,0x3804,0x3804,
0x3804,0x3804,0x3804,0x3804,0x1C18,0x0FF0,0x0000,0x0000});
letterMapping.put('V', new int[]{0x0000,0x0000,0x0000,0x7C1E,0x180C,0x1C18,0x0C10,0x0E30,
0x0E20,0x0760,0x0740,0x03C0,0x0380,0x0180,0x0000,0x0000});
letterMapping.put('W', new int[]{0x0000,0x0000,0x0000,0x7BCF,0x31C6,0x31C4,0x39CC,0x3BEC,
0x1BF8,0x1F78,0x1E78,0x0E70,0x0C30,0x0C20,0x0000,0x0000});
letterMapping.put('X', new int[]{0x0000,0x0000,0x0000,0x3E3E,0x0C18,0x0E30,0x0760,0x03C0,
0x01C0,0x03E0,0x0670,0x0C38,0x081C,0x7C3F,0x0000,0x0000});
letterMapping.put('Y', new int[]{0x0000,0x0000,0x0000,0x7E3E,0x1C08,0x0C10,0x0E30,0x0760,
0x03C0,0x01C0,0x01C0,0x01C0,0x01C0,0x0FF0,0x0000,0x0000});
letterMapping.put('Z', new int[]{0x0000,0x0000,0x0000,0x1FFE,0x381C,0x2038,0x0070,0x00E0,
0x01C0,0x0380,0x0600,0x0C06,0x380C,0x7FFC,0x0000,0x0000});未完,待续
letterMapping.put('a', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x07E0,0x1E78,
0x381C,0x07FC,0x1E1C,0x301C,0x303D,0x1FCE,0x0000,0x0000});
letterMapping.put('b', new int[]{0x0000,0x0000,0x0800,0x7800,0x1800,0x1800,0x19F0,0x1FFC,
0x1C0C,0x180E,0x180E,0x180E,0x181C,0x1FF0,0x0000,0x0000});
letterMapping.put('c', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E0,0x0F38,
0x181C,0x3800,0x3800,0x3804,0x1C0C,0x0FF8,0x0000,0x0000});
letterMapping.put('d', new int[]{0x0000,0x0000,0x0000,0x003C,0x001C,0x001C,0x03DC,0x0E7C,
0x381C,0x381C,0x381C,0x381C,0x1C3C,0x0FCE,0x0000,0x0000});
letterMapping.put('e', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E0,0x0F78,
0x180C,0x3FFE,0x3FFC,0x3800,0x1C0C,0x07F0,0x0000,0x0000});
letterMapping.put('f', new int[]{0x0000,0x0000,0x0000,0x01FE,0x0307,0x0700,0x3FF8,0x3FF8,
0x0700,0x0700,0x0700,0x0700,0x0700,0x3FF0,0x0000,0x0000});
letterMapping.put('g', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03EE,0x0E7E,
0x1818,0x1818,0x0FF0,0x1980,0x1FFC,0x383E,0x300E,0x1FF8});
letterMapping.put('h', new int[]{0x0000,0x0000,0x0800,0x7800,0x1800,0x1800,0x19F0,0x1FF8,
0x181C,0x181C,0x181C,0x181C,0x181C,0x7E3F,0x0000,0x0000});
letterMapping.put('i', new int[]{0x0000,0x0000,0x0000,0x01C0,0x01C0,0x0000,0x0FC0,0x0FC0,
0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x1FF8,0x0000,0x0000});
letterMapping.put('j', new int[]{0x0000,0x0000,0x0000,0x0038,0x0038,0x0000,0x01F8,0x01F8,
0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x1830,0x1FE0});
letterMapping.put('k', new int[]{0x0000,0x0000,0x0800,0x3800,0x1800,0x1800,0x187C,0x187C,
0x18E0,0x1B80,0x1EE0,0x1870,0x1838,0x7E3F,0x0000,0x0000});
letterMapping.put('l', new int[]{0x0000,0x0000,0x0080,0x0FC0,0x01C0,0x01C0,0x01C0,0x01C0,
0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x1FFC,0x0000,0x0000});
letterMapping.put('m', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x771C,0x7FFE,
0x31C6,0x31C6,0x31C6,0x31C6,0x31C6,0xFBEF,0x0000,0x0000});
letterMapping.put('n', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x79F0,0x7FF8,
0x181C,0x181C,0x181C,0x181C,0x181C,0x7E3F,0x0000,0x0000});
letterMapping.put('o', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E0,0x0F78,
0x380C,0x300E,0x700E,0x380E,0x181C,0x0FF0,0x0000,0x0000});
letterMapping.put('p', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x79E0,0x7FFC,
0x180E,0x180E,0x180E,0x180E,0x1C1C,0x1FF8,0x1800,0x7E00});
letterMapping.put('q', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03C0,0x1E7C,
0x381C,0x381C,0x301C,0x381C,0x181C,0x0FFC,0x001C,0x003E});
letterMapping.put('r', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7E3C,0x7EFE,
0x0F04,0x0E00,0x0E00,0x0E00,0x0E00,0x7FE0,0x0000,0x0000});
letterMapping.put('s', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E8,0x0E7C,
0x180C,0x0F80,0x03F8,0x101C,0x180C,0x1FF8,0x0000,0x0000});
letterMapping.put('t', new int[]{0x0000,0x0000,0x0000,0x0000,0x0100,0x0300,0x3FF8,0x3FF8,
0x0300,0x0300,0x0300,0x0304,0x030C,0x01F8,0x0000,0x0000});
letterMapping.put('u', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x783C,0x783C,
0x181C,0x181C,0x181C,0x181C,0x183C,0x0FDE,0x0000,0x0000});
letterMapping.put('v', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3E1E,0x3E1E,
0x0C18,0x0E30,0x0720,0x0360,0x03C0,0x0180,0x0000,0x0000});
letterMapping.put('w', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7BCF,0x7BCF,
0x39CC,0x39CC,0x1BE8,0x1E78,0x0E70,0x0C30,0x0000,0x0000});
letterMapping.put('x', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3E3C,0x3E3C,
0x0720,0x03C0,0x01C0,0x0670,0x0C38,0x7E7E,0x0000,0x0000});
letterMapping.put('y', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3E3E,0x3E3E,
0x0E18,0x0630,0x0360,0x03E0,0x01C0,0x0180,0x1900,0x3E00});
letterMapping.put('z', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1FF8,0x3FF8,
0x3070,0x01C0,0x0380,0x0704,0x1C0C,0x3FFC,0x0000,0x0000});
letterMapping.put('0', new int[]{0x0000,0x0000,0x0000,0x07F0,0x1C18,0x381C,0x380E,0x380E,
0x780E,0x380E,0x380E,0x381C,0x1C18,0x07F0,0x0000,0x0000});
letterMapping.put('1', new int[]{0x0000,0x0000,0x0000,0x01C0,0x0FC0,0x01C0,0x01C0,0x01C0,
0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x0FFC,0x0000,0x0000});
letterMapping.put('2', new int[]{0x0000,0x0000,0x0000,0x0FF8,0x181C,0x381C,0x181C,0x0038,
0x0070,0x01C0,0x0700,0x0C06,0x3FFC,0x3FFC,0x0000,0x0000});
letterMapping.put('3', new int[]{0x0000,0x0000,0x0000,0x0FF0,0x3838,0x381C,0x0038,0x03F0,
0x03F0,0x001C,0x000E,0x381C,0x381C,0x0FF0,0x0000,0x0000});
letterMapping.put('4', new int[]{0x0000,0x0000,0x0000,0x0030,0x00F0,0x01F0,0x0370,0x0C70,
0x1870,0x3070,0x3FFE,0x0070,0x0070,0x03FE,0x0000,0x0000});
letterMapping.put('5', new int[]{0x0000,0x0000,0x0000,0x1FFC,0x1800,0x1800,0x18C0,0x1FF8,
0x181C,0x001E,0x100E,0x381C,0x3818,0x0FF0,0x0000,0x0000});
letterMapping.put('6', new int[]{0x0000,0x0000,0x0000,0x07F8,0x0C3C,0x1808,0x3800,0x3FF8,
0x7C1C,0x780E,0x380E,0x380E,0x1C1C,0x07F0,0x0000,0x0000});
letterMapping.put('7', new int[]{0x0000,0x0000,0x0000,0x1FFE,0x3C0C,0x3018,0x0030,0x0060,
0x00C0,0x01C0,0x0380,0x0380,0x0380,0x0380,0x0000,0x0000});
letterMapping.put('8', new int[]{0x0000,0x0000,0x0000,0x0FF8,0x380C,0x300E,0x3C0C,0x1FF8,
0x0FF0,0x383C,0x300E,0x700E,0x380C,0x0FF0,0x0000,0x0000});
letterMapping.put('9', new int[]{0x0000,0x0000,0x0000,0x0FF0,0x3818,0x300C,0x700E,0x300E,
0x383E,0x1FEE,0x001C,0x1818,0x3C30,0x1FE0,0x0000,0x0000});
letterMapping.put(' ', SPACE);
}
}
下回来的字模提取软件也没有说明,我只能一个字母一个字母地提了。
我也来解一下
可以用Graphics2D来拿像素import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
import java.util.*;
import java.awt.image.*;public class test{
public test(){
BufferedImage image = new BufferedImage(78,20,BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
g.setFont(new Font("宋体", Font.PLAIN, 16));
g.drawString("我是白痴",2,image.getHeight()-2);
int[] p = image.getRGB(0,0,image.getWidth(),image.getHeight(),new int[image.getWidth()*image.getHeight()],0,image.getWidth());
for(int i=0;i<image.getHeight();i++)
for(int j=0;j<image.getWidth();j++)
System.out.print(p[i*image.getWidth()+j]==-1?(i%2==0?"*":"*"):" "+(j==image.getWidth()-1?"\n":""));
}
public static void main(String args[]){
new test();
}
} ** * * *
*** * * ******** * *
* * * * * * ************
* * * ******** *********** * *
* * * * * * * * *
*************** ******** * * * * **** ****
* * * * * ** * * *
* * * *************** * * * * * *
*** * * * *********** ******* * *
*** ** * * * * * * * * *
** * * * ****** * * * * * * *
* * * * * * * * * * * *
* ** * * * * * * * * * * ****
* * * * ** *********** * * * *
* * ** * ******* * * * * * *
* * *
非常短小,别人都看不出来是怎么回事。