mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 09:49:19 +02:00
smaller wallpaper files
This commit is contained in:
parent
10b09a2a4b
commit
5ef0e3e09a
8 changed files with 30 additions and 9 deletions
Binary file not shown.
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 11 KiB |
Binary file not shown.
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 25 KiB |
|
@ -26,6 +26,7 @@ import org.geometerplus.zlibrary.core.util.ZLColor;
|
|||
import org.geometerplus.zlibrary.core.library.ZLibrary;
|
||||
import org.geometerplus.zlibrary.core.view.ZLPaintContext;
|
||||
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
||||
import org.geometerplus.zlibrary.core.filesystem.ZLResourceFile;
|
||||
|
||||
import org.geometerplus.zlibrary.text.model.ZLTextModel;
|
||||
import org.geometerplus.zlibrary.text.view.*;
|
||||
|
@ -550,7 +551,7 @@ public final class FBView extends ZLTextView {
|
|||
final int infoWidth = context.getStringWidth(infoString);
|
||||
final ZLFile wallpaper = getWallpaperFile();
|
||||
if (wallpaper != null) {
|
||||
context.clear(wallpaper);
|
||||
context.clear(wallpaper, wallpaper instanceof ZLResourceFile);
|
||||
} else {
|
||||
context.clear(getBackgroundColor());
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ final class DummyPaintContext extends ZLPaintContext {
|
|||
DummyPaintContext() {
|
||||
}
|
||||
|
||||
public void clear(ZLFile wallpaperFile) {
|
||||
public void clear(ZLFile wallpaperFile, boolean doMirror) {
|
||||
}
|
||||
|
||||
public void clear(ZLColor color) {
|
||||
|
|
|
@ -41,7 +41,7 @@ abstract public class ZLPaintContext {
|
|||
protected ZLPaintContext() {
|
||||
}
|
||||
|
||||
abstract public void clear(ZLFile wallpaperFile);
|
||||
abstract public void clear(ZLFile wallpaperFile, boolean doMirror);
|
||||
abstract public void clear(ZLColor color);
|
||||
|
||||
private boolean myResetFont = true;
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.*;
|
|||
import org.geometerplus.zlibrary.core.application.ZLApplication;
|
||||
import org.geometerplus.zlibrary.core.view.ZLPaintContext;
|
||||
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
||||
import org.geometerplus.zlibrary.core.filesystem.ZLResourceFile;
|
||||
|
||||
import org.geometerplus.zlibrary.text.model.*;
|
||||
import org.geometerplus.zlibrary.text.hyphenation.*;
|
||||
|
@ -256,7 +257,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
|||
myContext = context;
|
||||
final ZLFile wallpaper = getWallpaperFile();
|
||||
if (wallpaper != null) {
|
||||
context.clear(wallpaper);
|
||||
context.clear(wallpaper, wallpaper instanceof ZLResourceFile);
|
||||
} else {
|
||||
context.clear(getBackgroundColor());
|
||||
}
|
||||
|
|
|
@ -67,20 +67,39 @@ public final class ZLAndroidPaintContext extends ZLPaintContext {
|
|||
private ZLFile myWallpaperFile;
|
||||
private Bitmap myWallpaper;
|
||||
@Override
|
||||
public void clear(ZLFile wallpaperFile) {
|
||||
public void clear(ZLFile wallpaperFile, boolean doMirror) {
|
||||
if (!wallpaperFile.equals(myWallpaperFile)) {
|
||||
myWallpaperFile = wallpaperFile;
|
||||
try {
|
||||
myWallpaper = new BitmapFactory().decodeStream(wallpaperFile.getInputStream());
|
||||
} catch (Throwable t) {
|
||||
myWallpaper = null;
|
||||
try {
|
||||
final Bitmap fileBitmap =
|
||||
new BitmapFactory().decodeStream(wallpaperFile.getInputStream());
|
||||
if (doMirror) {
|
||||
final int w = fileBitmap.getWidth();
|
||||
final int h = fileBitmap.getHeight();
|
||||
final Bitmap wallpaper = Bitmap.createBitmap(2 * w, 2 * h, fileBitmap.getConfig());
|
||||
for (int i = 0; i < w; ++i) {
|
||||
for (int j = 0; j < h; ++j) {
|
||||
int color = fileBitmap.getPixel(i, j);
|
||||
wallpaper.setPixel(i, j, color);
|
||||
wallpaper.setPixel(i, 2 * h - j - 1, color);
|
||||
wallpaper.setPixel(2 * w - i - 1, j, color);
|
||||
wallpaper.setPixel(2 * w - i - 1, 2 * h - j - 1, color);
|
||||
}
|
||||
}
|
||||
myWallpaper = wallpaper;
|
||||
} else {
|
||||
myWallpaper = fileBitmap;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (myWallpaper != null) {
|
||||
final int w = myWallpaper.getWidth();
|
||||
final int h = myWallpaper.getHeight();
|
||||
for (int cw = 0; cw < myWidth; cw += w) {
|
||||
for (int ch = 0; ch < myHeight; ch += h) {
|
||||
for (int cw = 0, iw = 1; cw < myWidth; cw += w, ++iw) {
|
||||
for (int ch = 0, ih = 1; ch < myHeight; ch += h, ++ih) {
|
||||
myCanvas.drawBitmap(myWallpaper, cw, ch, myFillPaint);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue