We have a jpg file. It is required to save it in png format, while cutting the background, i.e. make it transparent. Which way to look? Perhaps there are ready-made libraries for this? Also how to work with the background color, the so-called. sensitivity?
- First you need to define for yourself what is the "background". How to determine the background or not. As soon as you give a definition, you can immediately begin to write an algorithm on it, or look for a ready-made solution. - Vladyslav Matviienko
- In my case, the background is (preferably) similar shades of the same color surrounding the image in the middle. The user selects a point on the source image, which is the background and selects the sensitivity, i.e. borders of shades of the selected color. Next, I look at the image pixel by pixel. If the color of the pixel is included in the specified interval of shades, then we make it transparent (transparent, if not mistaken). Next, save the resulting array of pixels in a bitmap and save it all. To be honest - in my terrible bike, so I ask for the help of specialists. - Alexander Tkachenko
- Well, you already work with the stream, in Android there are both methods of compressing these formats - do what you want. Opened the stream -> set up alpha -> compression in png. bitmap.compress (Bitmap.CompressFormat.PNG, 100, out); But something tells me that you need something else - Shwarz Andrei
- If you look in general, then you are trying to make Photoshop for Android, without having any knowledge and resources, as I understand it. in practice, if you implement a bike, it will work really slowly. Such problems should be solved with the help of NDK, at least. And it is generally better on the server side. Your task is too difficult for you and for me. - Vladyslav Matviienko
- Shwarz Andrei, thanks for the reply. The vector is clear. - Alexander Tkachenko
|