OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <errno.h> | 5 #include <errno.h> |
6 #include <fcntl.h> | 6 #include <fcntl.h> |
7 #include <limits.h> | 7 #include <limits.h> |
8 #include <lzma.h> | 8 #include <lzma.h> |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 printf(" version %d.%d\n", hdr->major_version, hdr->minor_version); | 257 printf(" version %d.%d\n", hdr->major_version, hdr->minor_version); |
258 printf(" %d screens\n", hdr->number_of_screenlayouts); | 258 printf(" %d screens\n", hdr->number_of_screenlayouts); |
259 printf(" %d localizations\n", hdr->number_of_localizations); | 259 printf(" %d localizations\n", hdr->number_of_localizations); |
260 printf(" %d discrete images\n", hdr->number_of_imageinfos); | 260 printf(" %d discrete images\n", hdr->number_of_imageinfos); |
261 discard_file(ptr, length); | 261 discard_file(ptr, length); |
262 return 0; | 262 return 0; |
263 } | 263 } |
264 | 264 |
265 // Write out yaml | 265 // Write out yaml |
266 fprintf(yfp, "bmpblock: %d.%d\n", hdr->major_version, hdr->minor_version); | 266 fprintf(yfp, "bmpblock: %d.%d\n", hdr->major_version, hdr->minor_version); |
267 fprintf(yfp, "images:\n"); | |
268 offset = sizeof(BmpBlockHeader) + | 267 offset = sizeof(BmpBlockHeader) + |
269 (sizeof(ScreenLayout) * | 268 (sizeof(ScreenLayout) * |
270 hdr->number_of_localizations * | 269 hdr->number_of_localizations * |
271 hdr->number_of_screenlayouts); | 270 hdr->number_of_screenlayouts); |
| 271 // FIXME(chromium-os:12134): The bmbblock structure allows each image to be |
| 272 // compressed differently, but we haven't provided a way for the yaml file to |
| 273 // specify that. Additionally, we allow the yaml file to specify a default |
| 274 // compression scheme for all images, but only if that line appears in the |
| 275 // yaml file before any images. Accordingly, we'll just check the first image |
| 276 // to see if it has any compression, and if it does, we'll write that out as |
| 277 // the default. When this bug is fixed, we should just write each image's |
| 278 // compression setting separately. |
| 279 img = (ImageInfo *)(ptr + offset); |
| 280 if (img->compression) |
| 281 fprintf(yfp, "compression: %d\n", img->compression); |
| 282 fprintf(yfp, "images:\n"); |
272 for(i=0; i<hdr->number_of_imageinfos; i++) { | 283 for(i=0; i<hdr->number_of_imageinfos; i++) { |
273 img = (ImageInfo *)(ptr + offset); | 284 img = (ImageInfo *)(ptr + offset); |
274 sprintf(image_name, "img_%08x.bmp", offset); | 285 sprintf(image_name, "img_%08x.bmp", offset); |
275 fprintf(yfp, " img_%08x: %s # %dx%d %d/%d\n", offset, image_name, | 286 fprintf(yfp, " img_%08x: %s # %dx%d %d/%d\n", offset, image_name, |
276 img->width, img->height, | 287 img->width, img->height, |
277 img->compressed_size, img->original_size); | 288 img->compressed_size, img->original_size); |
278 if (todir) { | 289 if (todir) { |
279 sprintf(full_path_name, "%s/%s", todir, image_name); | 290 sprintf(full_path_name, "%s/%s", todir, image_name); |
280 bfd = open(full_path_name, | 291 bfd = open(full_path_name, |
281 O_WRONLY | O_CREAT | O_TRUNC | (overwrite ? 0 : O_EXCL), | 292 O_WRONLY | O_CREAT | O_TRUNC | (overwrite ? 0 : O_EXCL), |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 } | 393 } |
383 | 394 |
384 if (todir) | 395 if (todir) |
385 fclose(yfp); | 396 fclose(yfp); |
386 | 397 |
387 discard_file(ptr, length); | 398 discard_file(ptr, length); |
388 | 399 |
389 return 0; | 400 return 0; |
390 } | 401 } |
391 | 402 |
OLD | NEW |