The image is downloaded from the network. JPEG format. Along the edges of the image frame in 1px. How can I hide it?
2 answers
Solved the problem even more radical than in the very first answer. Picasso android librtary has a method:
RequestCreator.transform (Transformation transformation)
Implement the Transformation interface and its Bitmap transform (Bitmap source) method:
@Override public Bitmap transform(Bitmap source) { Bitmap bitmap = source.copy(source.getConfig(),true); //bitmap.recycle(); Log.d("Test","h = "+bitmap.getHeight()+" w= "+bitmap.getWidth()); for(int i = 0;i<(source.getWidth());i++){ for (int j=0;j<(source.getHeight());j++){ if (i == 0 || j == 0 || i == (source.getWidth()-1) || j == (source.getHeight()-1)){ bitmap.setPixel(i,j, Color.WHITE); } else { bitmap.setPixel(i,j,source.getPixel(i,j)); } } } source.recycle(); return bitmap; } And we use for example:
CropSquareTransformation transformator = new CropSquareTransformation ();
Picasso.with(getContext()).load(getContext() .getString(R.string.image_hotel_request_url)+hotel.getImage()) .transform(transformator) .into(photo); I’m not sure about the speed, still bit-by-bit image processing, but I’ve achieved the result - I delete the red frame one pixel wide along the image.
|
Solution to the forehead. I think if you insert a picture through srс , then how the Background can be done so, and change the color to the background color.
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <stroke android:width="1px" android:color="@android:color/white" /> //поменять на цвет фона </shape> - Well then I upload using Picasso. But now I will try this option - Djangorussia
|