OpenCores
URL https://opencores.org/ocsvn/z3/z3/trunk

Subversion Repositories z3

[/] [z3/] [trunk/] [bios/] [compressicon.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 charcole
#include <stdio.h>
2
#include <stdlib.h>
3
#include <math.h>
4
#include "icons.h"
5
 
6
#define MIN(a,b) ((a)<(b)?(a):(b))
7
 
8
int main(int argc, char **argv)
9
{
10
        char *data=malloc(sizeof(header_data));
11
        char *p=data;
12
        FILE *f;
13
        int i=0;
14
        while (i<320)
15
        {
16
                *(p++)=0;
17
                *(p++)=(45.0f*sinf((3.14f/2.0f)*(160.0f-fabsf(160.0f-i))/160.0f));
18
                i++;
19
        }
20
        i=0;
21
        while (i<128)
22
        {
23
                unsigned char r=header_data_cmap[i][0];
24
                unsigned char g=header_data_cmap[i][1];
25
                unsigned char b=header_data_cmap[i][2];
26
                *(p++)=(r&0xF8)|(g>>5);
27
                *(p++)=((g<<3)&0xE0)|(b>>3);
28
                i++;
29
        }
30
        i=0;
31
        while (i<sizeof(header_data))
32
        {
33
                char c=header_data[i];
34
                int n=i+1;
35
                int count=1;
36
                while (n<sizeof(header_data) && header_data[n]==c)
37
                {
38
                        count++;
39
                        n++;
40
                }
41
                i+=count;
42
                if (count==1)
43
                {
44
                        *(p++)=c;
45
                }
46
                else if (count==2)
47
                {
48
                        *(p++)=c;
49
                        *(p++)=c;
50
                }
51
                else
52
                {
53
                        while (count)
54
                        {
55
                                *(p++)=c|0x80;
56
                                *(p++)=MIN(255,count);
57
                                count-=MIN(255,count);
58
                        }
59
                }
60
        }
61
        printf("Before: %d After: %d Percent: %.1f%%\n", (int)(sizeof(header_data)+sizeof(header_data_cmap)), (int)(p-data), 100.0f*(p-data)/(float)(sizeof(header_data)+sizeof(header_data_cmap)));
62
        f=fopen("icons.dat", "w");
63
        fwrite(data, p-data, 1, f);
64
        fclose(f);
65
        free(data);
66
        return 0;
67
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.