마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

안드로이드에서 비트맵 이미지 문의

0 추천
안녕하세요 아래와 같이 비트맵 이미지를 만드는데 가끔 검정 테두리가 발생하네요

혹시 아마도 검정색 바탕에 이미지를 찍어내는거 같은데

혹시 검정을 흰색으로 바꿀수 없나요???

                    options.inSampleSize = calculateInSampleSize(options, actualWidth, actualHeight);

                    options.inJustDecodeBounds = false;

                    options.inPurgeable = true;

                    options.inInputShareable = true;

                    options.inTempStorage = new byte[16 * 1024];

                    Bitmap scaledBitmap = null;

                    try {

                        bmp = BitmapFactory.decodeFile(strImagePath, options);

                    } catch (OutOfMemoryError exception) {

                        exception.printStackTrace();

                    }

                    try {

                        scaledBitmap = Bitmap.createBitmap(actualWidth, actualHeight,Bitmap.Config.ARGB_8888);

                    } catch (OutOfMemoryError exception) {

                        exception.printStackTrace();

                    }

 

                    float ratioX = actualWidth / (float) options.outWidth;

                    float ratioY = actualHeight / (float) options.outHeight;

                    float middleX = actualWidth / 2.0f;

                    float middleY = actualHeight / 2.0f;

                    Matrix scaleMatrix = new Matrix();

                    scaleMatrix.setScale(ratioX, ratioY, middleX, middleY);

                    Canvas canvas = new Canvas(scaledBitmap);

                    canvas.setMatrix(scaleMatrix);

                    canvas.drawBitmap(bmp, middleX - bmp.getWidth() / 2, middleY - bmp.getHeight() / 2, new Paint(Paint.FILTER_BITMAP_FLAG));

                    ByteArrayOutputStream stream = new ByteArrayOutputStream();

                    scaledBitmap.compress(Bitmap.CompressFormat.JPEG, 80, stream);

                    byte[] rdata  = stream.toByteArray();
익명사용자 님이 2015년 10월 7일 질문

1개의 답변

0 추천

Canvas canvas = new Canvas(scaledBitmap); 

canvas .drawColor(Color.WHITE); // 요부분 추가하세요.

 

 

익명사용자 님이 2015년 10월 7일 답변
감사합니다. 그렇게 해볼께요
...