Chameleon

Chameleon Commit Details

Date:2010-07-25 02:20:09 (10 years 4 months ago)
Author:Tamás Kosárszky
Commit:232
Parents: 231
Message:Now loadThemeImage() and loadEmbeddedThemeImage() are unified along with the LOADPNG macro. Looking up the embedded image properties is stil in progress.
Changes:
M/branches/zef/i386/boot2/gui.h
M/branches/zef/i386/boot2/options.c
M/branches/zef/i386/boot2/Makefile
M/branches/zef/i386/boot2/gui.c

File differences

branches/zef/i386/boot2/gui.c
1818
1919
2020
21
22
23
24
25
26
2721
2822
23
24
2925
3026
3127
......
178174
179175
180176
181
182
177
183178
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
179
180
181
182
183
184
185
216186
217
187
218188
219189
220190
221
191
222192
223193
224194
......
244214
245215
246216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
247236
248237
249238
#ifdef EMBED_THEME
#include "art.h"
#define LOADPNG(img, alt_img) \
if (loadThemeImage(#img, alt_img) != 0) \
if (loadEmbeddedThemeImage(#img, __## img ##_png, __## img ##_png_len, alt_img) != 0) \
return 1;
#else
#define LOADPNG(img, alt_img) if (loadThemeImage(#img, alt_img) != 0) { return 1; }
#endif
#define LOADPNG(img, alt_img) if (loadThemeImage(#img, alt_img) != 0) { return 1; }
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
return -1;
}
#ifdef EMBED_THEME
static int loadEmbeddedThemeImage(const char *image, unsigned char *image_data, unsigned int image_size, int alt_image)
static int getEmbeddedImageIndexByName(const char *name)
{
inti;
uint16_twidth;
uint16_theight;
uint8_t*imagedata;
if ((i = getImageIndexByName(image)) >= 0)
{
if (images[i].image == NULL) {
images[i].image = malloc(sizeof(pixmap_t));
}
width = 0;
height = 0;
imagedata = NULL;
if (image_size > 0 && (loadEmbeddedPngImage(image_data, image_size, &width, &height, &imagedata)) == 0)
{
images[i].image->width = width;
images[i].image->height = height;
images[i].image->pixels = (pixel_t *)imagedata;
flipRB(images[i].image);
return 0;
}
else if (alt_image != IMG_REQUIRED && images[alt_image].image->pixels != NULL)
{
// Using the passed alternate image for non-mandatory images.
// We don't clone the already existing pixmap, but using its properties instead!
images[i].image->width = images[alt_image].image->width;
images[i].image->height = images[alt_image].image->height;
images[i].image->pixels = images[alt_image].image->pixels;
return 0;
}
}
return 1;
int i;
for (i = 0; i < sizeof(embeddedImages) / sizeof(embeddedImages[0]); i++)
{
if (strcmp(name, embeddedImages[i].name) == 0)
return i; // found the name
}
return -1;
}
#endif
static int loadThemeImage(const char *image, int alt_image)
{
chardirspec[256];
int i;
int i, e;
uint16_twidth;
uint16_theight;
uint8_t*imagedata;
flipRB(images[i].image);
return 0;
}
#ifdef EMBED_THEME
else if ((e = getEmbeddedImageIndexByName(image)) >= 0)
{
printf("found embedded image: %s, %d\n", image, e);
getc();
/*
if (image_size > 0 && (loadEmbeddedPngImage(image_data, image_size, &width, &height, &imagedata)) == 0)
{
images[i].image->width = width;
images[i].image->height = height;
images[i].image->pixels = (pixel_t *)imagedata;
flipRB(images[i].image);
return 0;
}
*/
return 0;
}
#endif
else if (alt_image != IMG_REQUIRED && images[alt_image].image->pixels != NULL)
{
// Using the passed alternate image for non-mandatory images.
branches/zef/i386/boot2/gui.h
134134
135135
136136
137
137
138138
139139
140140
int initGUI();
void drawBackground();
void drawDeviceIcon(BVRef device, pixmap_t *buffer, position_t p);
void drawDeviceIcon(BVRef device, pixmap_t *buffer, position_t p, bool isSelected);
void drawDeviceList(int start, int end, int selection);
void drawProgressBar(pixmap_t *blendInto, uint16_t width, position_t p, uint8_t progress);
branches/zef/i386/boot2/options.c
112112
113113
114114
115
115
116116
117117
118118
char dummy[80];
getBootVolumeDescription( gBootVolume, dummy, 80, true );
drawDeviceIcon( gBootVolume, gui.screen.pixmap, p );
drawDeviceIcon( gBootVolume, gui.screen.pixmap, p, false );
drawStrCenteredAt( (char *) msg, &font_small, gui.screen.pixmap, gui.countdown.pos );
// make this screen the new background
branches/zef/i386/boot2/Makefile
102102
103103
104104
105
106
107
108
105
106
107
108
109109
110110
111111
@echo "unsigned int*length;" >> $(SYMROOT)/art.h
@echo "} embededpng_t;" >> $(SYMROOT)/art.h
@echo "" >> $(SYMROOT)/art.h
@echo "embededpng_t embededImages[] = {" >> $(SYMROOT)/art.h
cd $(SYMROOT)/embed && find . -name '*.png' -exec sh -c "echo {.name = \`echo '\"'\`\`echo '{}' | cut -f 2 -d \"/\" | cut -f 1 -d \".\" \`\`echo '\"'\`, .pngdata = \`echo {} | tr / _ | tr . _ \`, .length = \&\`echo {} | tr / _ | tr . _ \`_len}," \; >> $(SYMROOT)/art.h
@echo "embededpng_t embeddedImages[] = {" >> $(SYMROOT)/art.h
@cd $(SYMROOT)/embed && find . -name '*.png' -exec sh -c \
"echo {.name = \`echo '\"'\`\`echo '{}' | cut -f 2 -d \"/\" | cut -f 1 -d \".\" \`\`echo '\"'\`, \
.pngdata = \`echo {} | tr / _ | tr . _ \`, .length = \&\`echo {} | tr / _ | tr . _ \`_len}," \; >> $(SYMROOT)/art.h
@echo "};" >> $(SYMROOT)/art.h
@echo "#endif /* !__BOOT2_ART_H */" >> $(SYMROOT)/art.h ;\

Archive Download the corresponding diff file

Revision: 232