Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Images for button widgets

Status
Not open for further replies.

fhutt

Programmer
Jul 7, 2006
79
0
0
AU
I have some images for placing onto button images such as:

image create bitmap imgdn -data {
#define down_width 16
#define down_height 16
static unsigned char down_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0xf8, 0x3f,
0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
}
image create bitmap imgup -data {
#define up_width 16
#define up_height 16
static unsigned char up_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00,
0xc0, 0x01, 0xe0, 0x03, 0xf0, 0x07, 0xf8, 0x0f,
0xfc, 0x1f, 0xfe, 0x3f, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
}

Does anyone know how to produce or where to find 'Left' and 'Right' arrows in the same format as the 'up' and 'down' arrows shown above?
Thanks
fhutt
 
I don't know where to find the bitmap strings you want but it shouldn't be too hard to build them.

First, start with a blank (all zeros) string and reconfigure it so it's easier to work with:
Code:
image create bitmap imgT -data {
#define up_width 16
#define up_height 16
static unsigned char up_bits[] = {
0x00, 0x00, 
0x00, 0x00, 
0x00, 0x00, 
0x00, 0x00,
0x00, 0x00, 
0x00, 0x00, 
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 
0x00, 0x00,
0x00, 0x00, 
0x00, 0x00
};
}

Now just build it up from the middle. Start by making all 1's on rows 8 and 9:
Code:
image create bitmap imgT -data {
#define up_width 16
#define up_height 16
static unsigned char up_bits[] = {
0x00, 0x00, 
0x00, 0x00, 
0x00, 0x00, 
0x00, 0x00,
0x00, 0x00, 
0x00, 0x00, 
0x00, 0x00,
0xff, 0xff,
0xff, 0xff,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 
0x00, 0x00,
0x00, 0x00, 
0x00, 0x00
};
}

Now work out from the middle dropping bits from the left and right (depending on which arrow). Remember that each hex word is "flipped" so it would be something like:
Code:
image create bitmap imgT -data {
#define up_width 16
#define up_height 16
static unsigned char up_bits[] = {
0x00, 0x00, 
0x00, 0x00, 
0x00, 0x00, 
0x00, 0x00,
0xc0, 0xff,
0xe0, 0xff,
0xf8, 0xff,
0xff, 0xff,
0xff, 0xff,
0xf8, 0xff,
0xe0, 0xff,
0xc0, 0xff,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00
};
}
and so on

_________________
Bob Rashkin
 
for instance, try this for a left arrow (made by taking the UP arrow, zeroing the right side, and mirroring the top to the bottom):
Code:
image create bitmap imgleft -data {
#define up_width 16
#define up_height 16
static unsigned char up_bits[] = {
0x00, 0x00, 
0x00, 0x00, 
0x00, 0x00, 
0x80, 0x00,
0xc0, 0x00,
0xe0, 0x00,
0xf0, 0x00,
0xf8, 0x00,
0xf8, 0x00,
0xf0, 0x00,
0xe0, 0x00,
0xc0, 0x00,
0x80, 0x00,
0x00, 0x00,
0x00, 0x00, 
0x00, 0x00
};
}

_________________
Bob Rashkin
 
OK. I have to admit this caught my interest (and things are a little slow today). Here's how to build a bitmap of 16x16 (as you have in your up and down arrows).

1. Take a piece of graph paper and mark out a 16x16 box of squares. For convenience mark a line right down the middle (separating the 16x8 squares on the left from those on the right).
2. Draw a closed figure inside that (16x16) box.
3. Every square inside the figure, and any containing the line (or not, as you like), gets a "1". All other squares get a "0".
4. On each (of 16) line, flip (you can probably do this in your head) the 8 squares on the left, and then those on the right (so for example, "00000111" "11111100" becomes "11100000" "00111111").
5. Convert these "binary" numbers to HEX and these are the elements of your bitmap.


I just did this for a left arrow:
Code:
image create bitmap imgT -data {
#define up_width 16
#define up_height 16
static unsigned char up_bits[] = {
0x00, 0x00,
0x00, 0x00,
0x00, 0x30,
0x00, 0x3c,
0x00, 0x3f,
0xe0, 0x3f,
0xf8, 0x3f,
0xfe, 0x3f,
0xfe, 0x3f,
0xf8, 0x3f,
0xe0, 0x3f,
0x00, 0x3f,
0x00, 0x3c,
0x00, 0x30,
0x00, 0x00,
0x00, 0x00
};
}

_________________
Bob Rashkin
 
Thank you Bob.
I followed your instructions and got:

image create bitmap imgRt -data {
#define up_width 16
#define up_height 16
static unsigned char up_bits[] = {
0x00, 0x00,
0x00, 0x00,
0x0c, 0x00,
0x3c, 0x00,
0xfc, 0x00,
0xfc, 0x03,
0xfc, 0x0f,
0xfc, 0x3f,
0xfc, 0x3f,
0xfc, 0x0f,
0xfc, 0x03,
0xfc, 0x00,
0x3c, 0x00,
0x0c, 0x00,
0x00, 0x00,
0x00, 0x00
};
}
This looks great.
fhutt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top