deltachat / deltachat-android

Email-based instant messaging for Android.
GNU General Public License v3.0
1.09k stars 144 forks source link

background color of transparent images should contrast to drawing color #700

Closed r10s closed 4 years ago

r10s commented 5 years ago

currently, transparent png or a gif file are shown just as transparent which results eg. black background shining through when shown in the gallery. while this is "okay by design", it fails the expectation of the user if there are some black drawings on a transparent backgrounds - which are visible in the chatlist (white background) but not in the enlarged gallery (black background).

i would suggest to show the background of enlarged png/gif in white therefore, the view in the chatlist is generally okay (tested in light in dark-mode).

however, just adding android:background="#ffffffff" to the corresponding items in zooming_image_view.xml or media_overview_gallery_item.xml is not sufficient as this colors more than the image which looks ugly.

the easiest way may be to replaces the pixels in the bitmap as described eg. at https://stackoverflow.com/questions/7237915/replace-black-color-in-bitmap-with-red , however, maybe there is also a loading option that fits our needs.

adbenitez commented 5 years ago

I hate to be a killjoy, but this will be what will happen for people wanting to share png files like this one: ryzom_logo there are an image with transparency there ^

adbenitez commented 5 years ago

what about the classic chess-like background? also instead of doing pixel replace stuff, you could set the background of a container for the pic to the chess-like grid, and make the container not to fill the whole parent but only be as bigger as its content (the image)

webratte commented 5 years ago

I absolutely agree with @adbenitez

A shared picture should stay as it sendet.

r10s commented 5 years ago

@adbenitez well, of course, if we switch the background color to white, white drawings are not visible.

however, in practise, i've received drawings with black-on-transparent, but never white-on-transparent - i know that they can exist, however, they seems to be less usual.

i do not like a checked background - this would make things ugly for all transparent pngs just to make things nicer for a few.

but we could use also a very light grey, close to white, that makes things visible in the very most cases then.

technically, it does not matter if we change the bits in the bitmap or add a colored layer below: the change of the bits are just done for displaying, the original files are not modified. we can do whatever is the simplest approach here.

adbenitez commented 5 years ago

@r10s I don't know why you don't like the checked background, this has been used to denote transparency since ever... and I don't love it nor hate it, it is just useful... anyway it will appear only on the image viewer, not in-chat, on top of that this is not the big deal, I don't ever had sent an image with transparency, so apart from giving my advice it is up to you folks to decide what to do :)

adbenitez commented 5 years ago

about replacing bitmap pixel, I said it because it sounds much more simple to use a layout than to play around with an array of pixel, I had done this pixel-stuff in Java, I guess in Android is the same, don't know which approach will be faster

r10s commented 5 years ago

it's technically more complicated than expected (as always :)

i did not find a way to force the used Glide-classes to use a background just for the image. using a checked-background would fit the whole screen then, and this looks ugly. i'd prefer whatever background, checked or not, fitting only the size of the image. and this seems doable more easily by changing the pixels as such.

maybe we could add an additional view or whatnot, however, this again may result in other issues (swiping would be different), and i would prefer a solution for this without affecting other parts.

r10s commented 5 years ago

so, anyone with some experiences with glide is very welcome :)

adbenitez commented 5 years ago

@r10s I have practically no Android programming experience but I considered setting a background for a layout container and putting the image on top of that sounds much more simple and less error prune than playing with pixels, as example, things are not white and black, (or visible and transparent in this case ;) what about if there are semi-transparent areas??? how you calculate the colour? that pixel Kung Fu sounds much more complicated to me... but well that is because I have no experience, maybe someone here can do this in a few lines of code... so sorry if I am saying something dummy :)

r10s commented 5 years ago

@adbenitez setting all pixels from transparent to white or whatever is very simple, a single loop, see the link in the first post.

it's more about when to do this, this requires some understanding of Glide.

for me, changing the layout view that should be zoomable and slideable sounds more complicated :)

however, any solution seems to be fine, again, it's more about glide (might also be that there is a simple command as with(...).setBackgroundColor() or so.

adbenitez commented 5 years ago

@r10s I had checked the post already but, replacing a colour isn't the same as replacing transparency, or I am wrong?? because there are pixels that are semi-transparent, anyway this Glide-thing may have an easy way to do it, but I don't think the link you posted with the loop would do the trick...

r10s commented 5 years ago

but I don't think the link you posted with the loop would do the trick...

maybe not one-to-one. anyway, of course, if there is a simple glide option, of course, this would be very welcome. i do not think all this is a real programming problem, however, it just needs some hours to dive into the problem.

whatever the solution will be: we should keep in mind that this issue does not add too much complexity and maintenance costs (eg. adding an additional filter to a Bitmap is easy compared with changed changed layouts at different places). also we should not make things worse for non-transparent images (which are the mass most time).

r10s commented 4 years ago

the issue is stale, it seems not to be easy to fix and even the browser show the things as they are - eg. the example from above in the safari browser:

Screen Shot 2020-01-06 at 21 00 36

as no-one seems to work on it i would avoid throwing much more time on it for now.