|
|
发表于 2014-6-2 17:03:11
|
显示全部楼层
本帖最后由 meigen 于 2014-10-10 20:19 编辑 - D9 F$ w$ m1 d& |& ~
# I9 g& c. \5 ^6 s, D! W# N3 [2 P
接14楼,单色图的提取稍微麻烦些,他里面只有数据部分而缺少文件头,这个是比较头疼的事情( Q3 n* m( f) [; `1 P: x& B8 e4 ?
先用ebdump提取出词典文本(本文),然后在里面获取单色图的代码(<1F44>开头,<1F64>结尾)- D# R$ h9 X4 q: V4 i: q
可以看到
: ^* Z# u# z4 x( O' r6 ]5 N" F<1F44><0001><w=200,h=256>xxx<1F64>[0001A4BD:0027]
! \; n" a+ T5 O& [这里的w=200,h=256表示图片的尺寸,这个参数后面会用到8 h. g, Z/ \; y: Z* A
然后<1F64>后面的这一段[0001A4BD:0027]就是单色图数据地址了
) f5 ?5 o1 ^: v先写个Demo 把所有地址都提取出来,顺便排一下序,去掉重复:& N4 y; u |. B3 _' @5 Q
- static void getMonoTag(String f) {
; F0 x+ k# U: M. \$ H - try {
) }& a0 s) `/ M G8 I2 h' v0 w - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(f+".txt"), "Shift_JIS"));
, ?& f/ M* ~1 ~# T - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f+".mono.txt"), "UTF-8"));
+ m, d3 N. e, Q; V - String line;" l: W- c* w- c2 |
- ArrayList<String> monos = new ArrayList<String>();# ^4 p5 h( |) ]7 |) p
- while (((line = reader.readLine()) != null)) {+ N7 R3 v% ]( t6 n1 F* L5 h
- while (line.contains("<1F64>")) { E7 d9 t: K* u# e8 y
- line = line.substring(line.indexOf("<1F64>") + 6);
! F! W& i/ u: x7 ~ - monos.add(line.substring(0, 15));* j3 n9 Q$ r6 }+ Q( C! S
- }0 D6 j, C( M, z& H
- }
4 g7 O# T6 K' D. I1 n - reader.close();
" {. p3 t1 H$ P: N! ~ - String[] monoa = new String[monos.size()];: \! j7 h/ X: _4 }
- monos.toArray(monoa);
9 I7 K# }; E* P8 g: c `" z0 O - Arrays.sort(monoa);
) w9 G0 q6 B+ ~: @ s - String last = "";
9 R% `/ v" e: ^# @: q/ N6 M - for (int i=0; i<monoa.length; i++) {
6 f" Y6 j6 z# `4 t8 i - if (!monoa[i].equals(last))( h$ c) I* m1 c& P* @
- writer.write(monoa[i] + "\r\n");
/ ^+ \: ]- J+ r- B! a3 g1 N7 ] - last = monoa[i];
) t( T% \/ { S9 |6 W, R' a1 X - }
# ~; n0 x. [/ ^' ] - writer.close();1 e2 P4 A |! X: s. U
- } catch (Exception e) {
4 W- p# l/ w: A0 c2 l8 @ - e.printStackTrace();
: | p; Q, \- G$ k/ ~ - }/ T& a8 X n9 U/ I
- }
复制代码 1 T+ G) Q& V. y% ?5 L
得到了一个.mono.txt的文件0 r2 [% m, O1 I8 w- |' ]: Z
然后开始提取:
8 p. y$ i( C6 ? d k% O上面有提到w=200,h=256这两个参数,不过epwing好像弄反了,200是高,256是宽。 - -
$ i: H1 }$ ?* T+ J8 D提取过程中需要手动加上图像的文件头,可自行百度bmp文件格式
" z- D* }* L& d: f7 I) n8 v2 Q- static final int WIDTH = 256;0 z! K2 l( P1 R. e8 b- m) z( C
- static final int HEIGHT = 200;
8 G; h* }: }( G8 A0 ? - static final int WIDTH2 = 32;
) U& B* a0 E! w% W9 r - static final int SIZE = WIDTH2 * HEIGHT;$ N9 P- g. {( T2 v1 K9 b
- static final int FILE_LEN = SIZE + 62;5 T. v1 Q7 Q8 S2 p! z
- static byte[] filehead = {0x42, 0x4d,
" e. E$ H$ _! A9 I* }1 T# s - (byte) (FILE_LEN & 0xff), (byte) ((FILE_LEN >> 8) & 0xff), (byte) ((FILE_LEN >> 16) & 0xff), (byte) ((FILE_LEN >> 24) & 0xff),
. B5 P7 K8 `9 {0 |6 J! t+ M$ u - 0, 0, 0, 0, 0x3e, 0, 0, 0};
: w3 Y; W0 z2 o+ t5 w8 |& j - static byte[] infohead = {0x28, 0, 0, 0,
3 c) k+ h0 t1 t6 N( D) b - (byte) (WIDTH & 0xff), (byte) ((WIDTH >> 8) & 0xff), (byte) ((WIDTH >> 16) & 0xff), (byte) ((WIDTH >> 24) & 0xff),2 ` M3 Y* d$ k4 s2 Z! p' J# w
- (byte) (HEIGHT & 0xff), (byte) ((HEIGHT >> 8) & 0xff), (byte) ((HEIGHT >> 16) & 0xff), (byte) ((HEIGHT >> 24) & 0xff),; V( k5 s! ^7 [4 }
- 1, 0, 1, 0, 0, 0, 0, 0,3 |! D: M9 I! k/ j x: w
- (byte) (SIZE & 0xff), (byte) ((SIZE >> 8) & 0xff), (byte) ((SIZE >> 16) & 0xff), (byte) ((SIZE >> 24) & 0xff),
) ?9 ^( V2 V+ K; ?; E3 M - 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, -1, -1, -1, 0, 0, 0, 0, 0};
8 F q! j5 u5 c. d; k8 I( } - static void getMonoPic(String f, String m) {" u8 R( L- }5 c: i ^2 I
- try {7 B u B/ t! X: H; _; @) Z* m
- BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(f+".txt"), "Shift_JIS"));
$ A3 k7 q7 I! M - BufferedReader reader2 = new BufferedReader(new InputStreamReader(new FileInputStream(m+".txt"), "UTF-8"));
, F: }6 A) V8 B9 s1 Q9 D - OutputStream out = null;2 Z2 ?) F6 h2 r' U1 Y! o
- String line = "";% @! [) v+ g* ?; J
- String line2 = reader2.readLine();
: A; k( m0 w# s) Y+ R) g0 z4 Y1 A( d - int block = 0;
6 b6 K: H- \3 T8 Z4 A) g1 A, ` - int block2 = Integer.parseInt(line2.substring(1, 9), 16);
7 m" O" g' j# M p/ b( i; T) `# u - int offs = Integer.parseInt(line2.substring(10, 14), 16); M( b# K6 n5 j$ c" z$ f& r- F
- byte[] temp = new byte[2048];
/ D ` o( ^4 |& s6 X, j - byte[] data = new byte[WIDTH2 * HEIGHT];
. o" s" [( N" [ - int[] idxs = new int[WIDTH2 * HEIGHT];
6 d. x# R% k2 j5 \2 x4 e - for (int i=0; i<HEIGHT; i++) {' ?" B3 A5 g$ I3 x$ \0 |2 N
- idxs[i * WIDTH2] = (HEIGHT - 1 - i) * WIDTH2;
; C0 a0 t4 w- w& X, a) A# s - for (int j=1; j<WIDTH2; j++)+ e' H9 }+ Q# B+ ~
- idxs[i * WIDTH2 + j] = idxs[i * WIDTH2 + j - 1] + 1;
8 [9 @0 g* c5 ~$ A - }& ]1 x" s! _6 C$ m) u) l/ M" J9 Y/ o
- int idx = 0;
5 T, d+ ~8 h+ L: L - int didx = 0;
/ O* q' E$ y8 {* G: Q - while (((line = reader.readLine()) != null)) {6 w2 f* ]* O: d- d/ C0 N
- if(line.startsWith("block")) {2 v8 g3 X$ N) Y* Q6 M/ |: g" k
- block = Integer.parseInt(line.substring(6, 11), 16);& p0 j: i! t, e
- idx = 0;6 _, S! k- \% N- X
- }( t2 ]9 Z9 r7 A/ o: \- e+ J
- if(line.startsWith("0")) {4 H0 ?" w" p* S$ p
- for(int i=0; i<16; i++) {) O7 k& ]% F6 f" ^
- int a = CHARS.indexOf(line.charAt(5+3*i));% z/ s' N- q8 A. W5 S3 R. s C
- int b = CHARS.indexOf(line.charAt(6+3*i));
# M/ l. Y+ |" i" t# F - temp[idx++] = (byte) (a << 4 | b);2 F. i( b# b) E3 ^/ H9 `% e3 g
- }( g( y" R. [$ }
- }5 C2 G' F; M+ K' G; _2 e0 k
- if (idx == 2048) {2 ?- m/ b- I: E8 W1 T% `
- if(block < block2) continue;
# x$ {: y. B& M) c( Q7 G* p - int start = offs;6 X" d/ N" O+ B/ N
- if(didx != 0) start = 0;* a$ O) Y" a' W8 K
- for(int i=0; i<2048; i++) {
0 |: x. Z* b( ~5 }7 Z. D - if(i >= start)
5 n$ G' W" o# T; S( ]9 B6 g - data[idxs[didx++]] = temp[i];8 r. c/ \. j: R8 O" l
- if(didx == WIDTH2 * HEIGHT) {
' R$ ^' g# b: T4 J - System.out.println(toHex(block2)+"."+toHex(offs));
8 N) _6 a# k' S: N- p" \. C5 O. _+ l - out = new BufferedOutputStream(new FileOutputStream("pic/"+toHex(block2)+toHex(offs)+".bmp"));
! _# @% p* H c. \ - out.write(filehead);4 A, N7 c7 N1 S1 d' z
- out.write(infohead);
* t8 J. `$ S# F5 ~1 A" a% w! p |6 A - out.write(data);# U9 C5 ~% Y9 m
- out.flush();# H' L+ m) Q4 D
- out.close();
" ^* j# ?5 Q2 V0 @6 n - line2 = reader2.readLine();: B" Z7 L" ]' f3 Y7 t: {
- if(line2 == null || line2.equals("")) {
& A8 x- G; ]) F" R, q) T$ J - reader.close();
; ^+ H4 h7 {4 b2 L - reader2.close();
+ P1 {) V; _& }/ \ Y - return; S+ T7 r' l+ q& D& j# s+ V- ^
- }# c; b; B$ y1 W3 e% x3 |
- block2 = Integer.parseInt(line2.substring(1, 9), 16);2 M, O/ V- m! c" |6 d
- offs = Integer.parseInt(line2.substring(10, 14), 16);
" h! K, C" J( i9 ^ - didx = 0;
7 n. B$ ]- h3 o) ?, h9 E$ k" S; J - }
; e. x+ f# Y" U* f - }
1 ]4 K, `, G3 q4 Z! d1 j - idx = 0;; k( h6 h% U j/ R* E6 k- k" a
- }
8 r2 @+ I& S8 s4 G/ } - }, b# [' R% |; W( x. `( \; t/ n
- reader.close();; r, ^1 e) l* I6 K7 _% t$ O0 l" `
- reader2.close();
4 q6 n* Y& }9 ^6 D8 g+ ? - } catch (Exception e) {
+ B; H- m. E- B! I3 @$ w( C - e.printStackTrace();
9 \7 u5 @- y8 p5 x8 p- T - }7 a, }8 [1 D5 x7 w/ }
- }
复制代码 % x1 G/ ]& `. J$ K
待编辑...
0 g+ y. S* y* a4 j& y* W) e+ M2 p; d* L9 @
回15楼:
H1 a8 Q% g9 i' `( O# h! w/ b+ g7 @$ Y
代码有一些要改动的地方, 我完善一下就传附件
) Q( w' E) Q) K6 j另外用英文说明这...{:11_336:} + E/ R5 |: \1 F& k
我先用中文注释一下, 然后再慢慢翻译 |
评分
-
1
查看全部评分
-
|