import java.io.*;
import android.app.*;
import android.content.*;
import android.content.res.*;
import android.graphics.*;
import android.os.*;
import android.util.*;
import android.view.*;
public class BitmapTest extends Activity
{
class RenderView extends View
{
Bitmap bob565;
Bitmap bob4444;
Rect dst = new Rect();
public RenderView(Context context)
{
super(context);
try
{
AssetManager assetManager = context.getAssets();
InputStream inputStream = assetManager.open("bobrgb888.png");
bob565 = BitmapFactory.decodeStream(inputStream);
inputStream.close();
Log.d("BitmapTest", "bobrgb888.ong format: " + bob565.getConfig());
inputStream = assetManager.open("bobargb8888.png");
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_4444;
bob4444 = BitmapFactory.decodeStream(inputStream, null, options);
inputStream.close();
Log.d("BitmapTest", "bobargb8888.png format: " + bob4444.getConfig());
}
catch(IOException e)
{}
finally
{}
}
protected void onDraw(Canvas canvas)
{
dst.set(50, 50, 350, 350);
canvas.drawBitmap(bob565, null, dst, null);
canvas.drawBitmap(bob4444, 100, 100, null);
invalidate();
}
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(new RenderView(this));
}
}
import android.app.*;
import android.content.*;
import android.content.res.*;
import android.graphics.*;
import android.os.*;
import android.util.*;
import android.view.*;
public class BitmapTest extends Activity
{
class RenderView extends View
{
Bitmap bob565;
Bitmap bob4444;
Rect dst = new Rect();
public RenderView(Context context)
{
super(context);
try
{
AssetManager assetManager = context.getAssets();
InputStream inputStream = assetManager.open("bobrgb888.png");
bob565 = BitmapFactory.decodeStream(inputStream);
inputStream.close();
Log.d("BitmapTest", "bobrgb888.ong format: " + bob565.getConfig());
inputStream = assetManager.open("bobargb8888.png");
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_4444;
bob4444 = BitmapFactory.decodeStream(inputStream, null, options);
inputStream.close();
Log.d("BitmapTest", "bobargb8888.png format: " + bob4444.getConfig());
}
catch(IOException e)
{}
finally
{}
}
protected void onDraw(Canvas canvas)
{
dst.set(50, 50, 350, 350);
canvas.drawBitmap(bob565, null, dst, null);
canvas.drawBitmap(bob4444, 100, 100, null);
invalidate();
}
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(new RenderView(this));
}
}
'코드조각모음' 카테고리의 다른 글
[android015] SurfaceView, UI스레드와 Rendering스레드 분리 예제 (0) | 2011.11.06 |
---|---|
[android014] 트루타입 폰트 사용 예제 (0) | 2011.11.06 |
[android012] 캔바스 예제 - 도형 그리기 (0) | 2011.11.06 |
[android011] 캔바스 예제 - 랜덤 색상 배경화면 (0) | 2011.11.06 |
[android010] 전체화면 예제 (0) | 2011.11.06 |