18 |
public int texId; |
public int texId; |
19 |
public float x0, y0, x1, y1; |
public float x0, y0, x1, y1; |
20 |
/** Width and height in points. |
/** Width and height in points. |
21 |
|
* Useful for aspect ratio and absolute scaling. |
22 |
*/ |
*/ |
23 |
public float w, h; |
public float w, h; |
24 |
|
double getTexCoord(int ind, double c) { |
25 |
|
double c0 = (ind == 1 ? y0 : x0); |
26 |
|
double c1 = (ind == 1 ? y1 : x1); |
27 |
|
return c0 + (c1-c0)*c; |
28 |
|
} |
29 |
}; |
}; |
30 |
static HashMap pages = new HashMap(); |
static HashMap pages = new HashMap(); |
31 |
|
|
34 |
GZZGL.Image img = GZZGL.createImage(file); |
GZZGL.Image img = GZZGL.createImage(file); |
35 |
this.w = img.getSize(0); |
this.w = img.getSize(0); |
36 |
this.h = img.getSize(1); |
this.h = img.getSize(1); |
37 |
this.rect = GZZGL.createTexRect(img); |
int overw = 1; while(overw < w) overw *= 2; |
38 |
|
int overh = 1; while(overh < h) overh *= 2; |
39 |
|
tex = GZZGL.createTexture(); |
40 |
|
tex.loadNull2D(0, "R3_G3_B2", overw, overh, 0, "RGB", "FLOAT"); |
41 |
|
tex.loadSubImage(0, img, 0, 0); |
42 |
|
// tex.shade(overw, overh, 0, 1, "LUMINANCE4", "LUMINANCE", "noise", new String[] {}); |
43 |
|
rect = new Rect(); |
44 |
|
rect.texId = tex.getTexId(); |
45 |
|
rect.x0 = 0; |
46 |
|
rect.y0 = 0; |
47 |
|
rect.x1 = w / (float)overw; |
48 |
|
rect.y1 = h / (float)overh; |
49 |
|
img = null; |
50 |
|
System.gc(); // GC the image, it's big. |
51 |
} |
} |
52 |
GZZGL.TexRect rect; |
GZZGL.Texture tex; // Need to save this so it won't get GC'ed. |
53 |
int w; |
Rect rect; |
54 |
int h; |
/** Width and height in pixels of the loaded image. |
55 |
|
*/ |
56 |
|
int w, h; |
57 |
} |
} |
58 |
|
|
59 |
/** Return a Rect containing the first page of the |
/** Return a Rect containing the first page of the |
74 |
|
|
75 |
LoadedTexRect rect = getImage(file); |
LoadedTexRect rect = getImage(file); |
76 |
r = new Rect(); |
r = new Rect(); |
77 |
r.texId = rect.rect.getTexId(); |
r.texId = rect.rect.texId; |
78 |
r.x0 = (float)rect.rect.getTexCoord(0, resmult * p.x / rect.w); |
r.x0 = (float)rect.rect.getTexCoord(0, resmult * p.x / rect.w); |
79 |
r.x1 = (float)rect.rect.getTexCoord(0, resmult * (p.x+d.width) / rect.w); |
r.x1 = (float)rect.rect.getTexCoord(0, resmult * (p.x+d.width) / rect.w); |
80 |
r.y0 = (float)rect.rect.getTexCoord(1, resmult * p.y / rect.h); |
r.y0 = (float)rect.rect.getTexCoord(1, resmult * p.y / rect.h); |