I have a jpg format picture:
And I want to extract the rgb value from every pixel , but I found that the values are diiferent from Android and Photoshop .
Like the first pixel(x=0,y=0) , the rgb value which androidTest got is 216,231,238 while photoshop is 217,230,238.
Here are my android codes:
InputStream inputStream = appContext.getAssets().open("small_"+ pictureNum +".jpg");
bitmap = BitmapFactory.decodeStream(inputStream);
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int color;
int red, green, blue;
List<Short> pixelList = new ArrayList<>();
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
color = bitmap.getPixel(x, y);
pixelList.add((short) Color.red(color));
pixelList.add((short) Color.green(color));
pixelList.add((short) Color.blue(color));
}
}
I am using Android Studio 3.1.2 .
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}}