How to display a background image for a kivy button unchanged? - kivy

I want to use a background image for a kivy button. I have used the following builder string:
<MenuScreen>:
BoxLayout:
Button:
background_normal: './Pictures/my_background.png'
The image is displayed, however, it is much darker than expected and partially inverted. What do I have to do in order to display my original image without changes?
The resulting button
Original image

I think your problem is that the two colors in your image are grey and transparent (the white appearing areas are actually transparent in your image). In a Button, the background_normal image is multiplied by the background_color which is also a shade of grey by default. So what you end up with is the background grey showing through your transparent areas (white areas above) and your grey appearing everywhere else. So there is not much contrast. See the Button Docs for more information.
You can modify your image (using something like Gimp) to replace the transparent areas with a white color, and perhaps change the grey colors in your image with black. The distortion of the image is due to Kivy fitting your image to the button size.
Here is your image edited as I described. You should be able to click on it and download it.

Related

tab bar icons appear as blue squares

Well, the title says most of it. I've tried with icon sets of 75/50/25 px and 72/48/24 px, as stated by different guides, but when I run the app in Xcode, the icons appear as (appropriately sized) blue squares. The icons are all black and white .png files, with negative images for the selected images. Any suggestions would be appreciated.
This might not fix your issue, and also may seem very obvious. But I'll put it here just in case it helps anyone.
First of all, I'm going to point out scenarios to check that can get you in this state that may or may not apply to everyone:
The asset's render type is set to Template Image
You are changing the tabBar.tintColor
If either of these are true and you are getting a solid colored square as your icon, the first thing I would check is the actual image you are using. It is probably an image/icon sitting on a white background or something like that rather than a transparent background.
If you are using a .png, .pdf, or .svg icon and want to tint the icon, you will need a transparent background. Transparency doesn't exist for .jpegs so they just won't work for tinting the icons.
This is because changing the tint will tint the whole image. If there isn't transparency, Xcode will have no idea what is icon and what is background. So a 40x40 icon just becomes a colored square.
Another benefit of using a transparent background will be now instead of having multiple images for selected/unselected states, you can just set the desired colors for .selected and .normal states and use one image.
Okay, the solution is NOT to set the image to render as image, but to use an alpha 0 background instead of a white background on the icon image.
Another tip. Don't name your image assets the same name as iOS System icons/glyphs. I had a download icon labeled download(.png). After renaming the issue disappeared. Very inconsistent behavior.

GIMP: Setting entire foreground to a particular colour

In GIMP version 2.8, I have an image with a black foreground, and a transparent background. I want to set the entire foreground to red, instead of black. What's the simplest way of doing this?
I have tried using the fuzzy select tool and doing a bucket fill on the selection, but this doesn't seem to select the entire foreground. After the bucket fill, there is still a black line around the edge of the foreground image. So it seems that the fuzzy selector didn't select the entire foreground. On closer inspection, the edges of the foreground are not perfectly black, but have some grey pixels. But when using the fuzzy selection, I set a very high threshold (250), so I would have thought this this would select the entire foreground, including the grey pixels.
Any help? Thanks!
The gray pixels aren't grey, they are partially transparent black pixels. If you replace black, you want to keep that partial transparency because this is what gives smooth edges. And there is an easy solution:
Set the alpha-lock of the layer (this is the checkerboard icon at the top of the Layers list) (or in code: gimp-layer-set-lock-alpha)
Do not use selection.
Bucket-fill the layer with the required color. The alpha-lock will preserve the opacity of the pixels.

iOS 8 bar button item image color [duplicate]

I am adding my own image icon in the bottom of the tab bar, but it only shows a grey square and the title.
How can I fix this?
The problem is that your image lacks transparency. The tab bar expects your image to be a transparency mask (also called a template) - only its degree of transparency / opacity is taken into account. Your image is completely solid opaque, so it appears as a solid square.
Either fix your image, or derive from it an image whose rendering mode is Always Original to force that actual drawing of the image to appear instead of its opacity.

make button glyph have a transparent background in delphi 7?

I have four TSpeedButton objects, each with a BMP file assigned as a glyph for the button image. For whatever reason, delphi has decided that two of the button images should have a transparent background and two should have a white background. I created the bitmaps myself, so they are all saved at the same color depth and are using pure white (not some shade of almost white) for the background and have background color in all four corner pixels of the image.
Why would some of the glyph images show up with a transparent background and some not? What is the criterion for making the background transparent? How can I make my button images all have transparent backgrounds instead of half of them having transparent backgrounds?
Ken's comment
Delphi's glyph handling uses the pixel in the lower-left corner to determine the transparent color. All pixels that match that color should be shown as transparent. Does the lower-left pixel color match in all of the glyphs, and does it match the areas you want to be transparent? (Without the images, it's hard to tell what the problem is, but I thought I'd post this as a potential for investigation.)
appeared to hold the correct answer (sorry, can't accept a comment as the right answer!). The image I was using had a shadow reaching to the lower left corner so it was almost white in that corner and exactly white in all the other corners.
I had a similar problem with D5 and I cludged a fix for this as I never found out why it was happening.
Define the image size one Row taller than the actual image/glyph is. This will force the image to be written starting at the top left and stop just before the last row. That will force the use of a non-transparent color and the extra row below the image is not visually noticeable.

Remove Transparency From Glyph.Data in SpeedButtons

I have an old app (Delphi 5) which I want to give it some changes.
I have set a Glyph.Data for a speedbutton, but some colors are transparent and in some places I see small white dots on my image, I do not want to set transparency for the image, How to remove it (transparency)?
Any help is really appreciated.
Thanks :)
The transparency is a color that is not drawn.
You just have to change the image or set another color as the transparent one.
From Delphi 6 Help
Transparent color
Use the Transparent color drop-down to
specify which color is used to create
a mask for drawing the image
transparently. The default transparent
color is the color of the bitmap's
left-most pixel in the bottom line.
You can also change the transparent
color by clicking directly on a pixel
in the selected image.
When an image has a transparent color,
any pixels in the image of that color
are not rendered in that color, but
instead appear transparent, allowing
whatever is behind the image to show
through.
If the image is an icon, Transparent
color appears grayed and the
transparent color is set to clNone.
This is because icons are already
masked.
Set TSpeedButton.Transparent to False.
I have found the answer, Delphi thinks the transparent color is the color of most left - bottom pixel of this image. So If I set a color which is not used in my image in the most left-bottom of my image, then Delphi only will make that small pixel transparent and other parts of my image will be OK without transparency, So this post is completed by myself :))

Resources