Enable / fix iOS module, closes #29

This commit is contained in:
Longri
2016-06-19 21:14:39 +02:00
committed by Emux
parent 2b171739aa
commit 11d7002841
14 changed files with 1519 additions and 306 deletions

View File

@@ -1,3 +1,17 @@
/*
* Copyright 2016 Longri
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.ios.backend;
import java.io.IOException;
@@ -8,53 +22,54 @@ import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Canvas;
import org.oscim.backend.canvas.Paint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* iOS specific implementation of {@link CanvasAdapter}<br>
* <br>
* Created by Longri on 25.06.16.
*/
public class IosGraphics extends CanvasAdapter {
private static final IosGraphics INSTANCE = new IosGraphics();
public static CanvasAdapter get() {
return INSTANCE;
}
static final Logger log = LoggerFactory.getLogger(IosGraphics.class);
public static void init() {
g = INSTANCE;
CanvasAdapter.init(new IosGraphics());
}
@Override
public Canvas getCanvas() {
protected Canvas newCanvasImpl() {
return new IosCanvas();
}
@Override
public Paint getPaint() {
protected Paint newPaintImpl() {
return new IosPaint();
}
@Override
public Bitmap getBitmap(int width, int height, int format) {
protected Bitmap newBitmapImpl(int width, int height, int format) {
return new IosBitmap(width, height, format);
}
@Override
public Bitmap decodeBitmap(InputStream inputStream) {
protected Bitmap decodeBitmapImpl(InputStream inputStream) {
try {
return new IosBitmap(inputStream);
} catch (IOException e) {
e.printStackTrace();
log.error("decodeBitmapImpl",e);
return null;
}
}
@Override
public Bitmap loadBitmapAsset(String fileName) {
return new IosBitmap(fileName);
// try {
// return createBitmap(fileName);
// } catch (IOException e) {
// e.printStackTrace();
// }
// return null;
protected Bitmap loadBitmapAssetImpl(String fileName) {
try {
return new IosBitmap(fileName);
} catch (IOException e) {
log.error("loadBitmapAssetImpl",e);
return null;
}
}
}