2013-12-19 1 views
0

Я читаю файл jpg в bitmap. Файл, который я читаю, имеет размеры 1600x1600, но растровое изображение имеет размеры 600x600. Почему он сокращается? Вот мой код:Android предотвращает уменьшение растрового изображения при чтении файла

BitmapFactory.Options options = new BitmapFactory.Options(); 
options.inScaled = false; 
options.inPreferredConfig = Bitmap.Config.ARGB_8888; 
options.inMutable = true; 

b = BitmapFactory.decodeFile(imageFile, options); 

Log.d("###", "bitmapWidth: " + b.getWidth()); 
Log.d("###", "bitmapHeight: " + b.getHeight()); 

я получаю следующий журнал:

12-19 10:03:10.551: D/###(4125): bitmapWidth: 600 
12-19 10:03:10.551: D/###(4125): bitmapHeight: 600 

Как вы можете видеть, у меня есть inScaled флаг установлен в ложь. Почему он сокращается?

EDIT: Я даже пытался с inJustDecodeBounds и я получил тот же результат.

ответ

2

Ваш код sholud работы, как указано here но не получаю, почему это не работает ..

Добавьте эти строки

options.inDensity = 0; 
    options.inTargetDensity = 0; 
    options.inSampleSize = 1; 

1, будет работает как написан here

"The sample size is the number of pixels in either dimension that correspond to a single pixel in the decoded bitmap. For example, inSampleSize == 4 returns an image that is 1/4 the width/height of the original, and 1/16 the number of pixels. Any value <= 1 is treated the same as 1. Note: the decoder uses a final value based on powers of 2, any other value will be rounded down to the nearest power of 2." 
+0

Таким образом, я получил 300x300. Это еще меньше :) – nikmin

+0

Oppss try ma отредактированный ответ..sorry ma error –

+0

он должен быть int value – nikmin