void HariMain (void) { api_initmalloc (); char *buf = api_malloc (144 * 164); int win = api_openwin (buf, 144, 164, -1, "color"); for (int y = 0; y < 128; y++) { for (int x = 0; x < 128; x++) { buf [(x + 8) + (y + 28) * 144] = rgb2pal(x * 2, y * 2, 0, x, y); } } api_refreshwin (win, 8,28, 136, 156); api_getkey (1); api_end(); }
void UcanMain(void) { char *buf; int win, x, y; api_initmalloc(); buf = api_malloc(144 * 164); win = api_openwin(buf, 144, 164, -1, "color2"); for (y = 0; y < 128; y++) { for (x = 0; x < 128; x++) { buf[(x + 8) + (y + 28) * 144] = rgb2pal(x * 2, y * 2, 0, x, y); } } api_refreshwin(win, 8, 28, 136, 156); api_getkey(1); /* 等待任意键按下 */ api_end(); }
void main() { char buf[144 * 164]; int win, x, y , r, g, b; win = api_openwin(buf, 144, 164, -1, "color"); for(y = 0; y < 128; y++) for(x = 0; x < 128; x++) { r = x * 2; g = y * 2; b = 0; buf[(x + 8) + (y + 28) * 144] = rgb2pal(r, g, b, x, y); } api_refreshwin(win, 8, 28, 136, 156); api_getkey(1); return; }
void HariMain(void) { char* buf; int win, x, y; init_mem(); buf = (char*)malloc(144 * 164); win = win_open(buf, 144, 164, -1, "WIN-COLOR2"); for (y = 0; y < 128; ++y) { for (x = 0; x < 128; ++x) buf[(x + 8) + (y + 28) * 144] = rgb2pal(x * 2, y * 2, 0, x, y); } win_refresh(win, 8, 28, 136, 156); getkey(1); api_end(); }
void load_background_pic(char* buf_back, int *fat) { struct DLL_STRPICENV env; char * filebuf, *p; char filename[20] ; sprintf(filename, "night.bmp"); p = filename; int i, j, fsize, info[8]; struct RGB picbuf[300*300], *q; //这里的空间不能太大,否则内核的栈不够用了 if(picbuf == 0) { return; } struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO; char strbuf[50]; sprintf(strbuf,p); boxfill8(binfo->vram,binfo->scrnx, COL8_848484, 10, 200-16, 200+8*50, 200+16); putfonts8_asc(binfo->vram, binfo->scrnx, 10, 200-16, COL8_000000, strbuf); //查找文件 struct FILEINFO *finfo = file_search(p,(struct FILEINFO *) (ADR_DISKIMG + 0x002600), 224); if( finfo ==0 ) //文件找不到 return; sprintf(strbuf,"found %s, clustno = %d, size = %d", filename, finfo->clustno, finfo->size); boxfill8(binfo->vram,binfo->scrnx, COL8_848484, 10, 200, 200+8*50, 200+16); putfonts8_asc(binfo->vram, binfo->scrnx, 10, 200, COL8_000000, strbuf); fsize = finfo->size; //加载文件内容 filebuf = file_loadfile2(finfo->clustno,&fsize,fat); /* 检查文件类型*/ if (info_BMP(&env, info, fsize, filebuf) == 0) { /* 不是BMP */ if (info_JPEG(&env, info, fsize, filebuf) == 0) { /* 不是JPEG */ //api_putstr0("file type unknown.\n"); //api_end(); memman_free_4k((struct MEMMAN *) MEMMAN_ADDR, (int)filebuf, fsize); return; } } sprintf(strbuf,"load file contents, x = %d, y = %d, info[0] = %d",info[2],info[3],info[0]); boxfill8(binfo->vram,binfo->scrnx, COL8_848484, 10, 200+16, 200+8*50, 200+16+16); putfonts8_asc(binfo->vram, binfo->scrnx, 10, 200+16, COL8_000000, strbuf); /* 上面其中一个info函数调用成功的话,info中包含以下信息 */ /* info[0] : 文件类型 (1:BMP, 2:JPEG) */ /* info[1] : 颜色数信息 */ /* info[2] : xsize */ /* info[3] : ysize */ if (info[2] > 500 || info[3] > 400) { //error("picture too large.\n"); memman_free_4k((struct MEMMAN *) MEMMAN_ADDR, (int)filebuf, fsize); return; } if (info[0] == 1) { i = decode0_BMP (&env, fsize, filebuf, 4, (char *) picbuf, 0); } else { i = decode0_JPEG(&env, fsize, filebuf, 4, (char *) picbuf, 0); } sprintf(strbuf,"parse image, i = %d",i); boxfill8(binfo->vram,binfo->scrnx, COL8_848484, 10, 200+16+16, 200+8*50, 200+16+16+16); putfonts8_asc(binfo->vram, binfo->scrnx, 10, 200+16+16, COL8_000000, strbuf); if (i != 0) { //error("decode error.\n"); memman_free_4k((struct MEMMAN *) MEMMAN_ADDR, (int)filebuf, fsize); return; } buf_back = buf_back + binfo->scrnx * ( (binfo->scrny - 24) / 2 - info[3] / 2); for (i = 0; i < info[3]; i++) { p = buf_back + i * binfo->scrnx + binfo->scrnx / 2 - info[2] / 2; q = picbuf + i * info[2]; for (j = 0; j < info[2]; j++) { p[j] = rgb2pal(q[j].r, q[j].g, q[j].b, j, i); } } memman_free_4k((struct MEMMAN *) MEMMAN_ADDR, (int)filebuf, fsize); }