Notifications
Clear all

[Closed] Set pixels vs bitmap image

I get fed up making images for buttons in UI’s the whole time, and much of the time i just want a small color on the button to differentiate it from others.

hence –

B1 = bitmap 90 10 color: (color 75 75 75)
button btn18 "" width:90 height:10 images:#(B1, undefined, 1, 1, 1, 1, 1)

if i wanted to make a disabled state for the button, i would have to have a bitmap twice as wide to incorporate the disabled state color.

Can i make this with the set pixels part of bitmap? Are there issues in terms of efficiency doing things this way or is it better to use a jpg of a flat colour?

i know what you’re thinking, there’s nowt so efficient as a button with “button” written on it but i guess i just want to know the merits of each way.

13 Replies

Hey Peter,

To make the triangular button, I created the image in photoshop. Then I have extracted the coordinate information using getPixel for black colors. From there I used the same coordinates to make them black on a white background, which acts as a mask.

From there it’s just a matter of creating a single colored bitmap like bitmap 1 1 color:black to actually create the button. In this case I set the color to the text color in the active ui, which ensures that it will be visible in dark colored UIs too.

Please let me know if you have any questions.

Light

Hey Light,

Thanks for your reply! What a great way of doing this. So the image is a kind of reference thing just until you can get the pixel information and store it as an array? I assume you run a separate script to generate the array of pixel information from the image and then store that permanently as your “arr” array.

Getting the text color is a neat idea, im always getting slight issues because i run a dark UI and everyone else seems to like grey. (i guess that makes me the freak)

Are there any memory or speed issues associated with this?

Thanks for your input Light, it is greatly appreciated.

You can get the pixels with a fn like this:

 fn getPixelCoords file color =
 (
     local img = openBitmap file
     local arr = #(); for i = 1 to img.width do join arr (for f = 1 to img.height where (getPixels img[i,f] 1)[1] == color collect [i,f])
     arr
 )

As for memory and speed issues, there isn’t one for a very small and 2 colored image like this (where we only set the minority pixels on top of a bitmap where the color is of the majority), and using a 1×1 bitmap for the background color of the button enhances the speed even more.

Light

Brilliant! i cant wait to try this out. In the C4 struct you specify a 14×14 as the background (white) bitmap mask, but you mention that you can use a 1×1 background image for speed. but i guess its all hypothetical on bitmaps this small! thanks again for your help!

Mask is 14×14, which should be 1:1 ratio, but the image behind should be made of a single color, which is visible through the mask.

Make sense?

Light

got it! you are a setpixels god!

Please post the results when you are done, if you are allowed. Just wondering the UI you have in mind.

Thanks,
Light

Sure thing! I think mostly i’ve been inspired with the idea of consistency between UI background colors, in the past i’d have to make separate map files for each. So I’ll post as soon as i work on something. I dont know about you, it seems to take me three times as long to make the UIs than it does to write the code!

I also spend a great deal of time designing and planning the UIs, as it really improves the tool’s quality and workflow. But after when it is done, coding generally takes alot of time, especially since I am so keen to write things shorter, faster and cleaner.

Light

Page 1 / 2