Rev 4544 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4411 | leency | 1 | struct s_image |
2 | { |
||
3 | dword *image; |
||
4 | char path[4096]; |
||
5 | }; |
||
4486 | leency | 6 | |
4411 | leency | 7 | s_image pics[100]; //pics = mem_Alloc( 100*sizeof(s_image) ); |
8 | |||
4491 | leency | 9 | struct ImageCache { |
4486 | leency | 10 | int pics_count; |
11 | void Free(); |
||
4544 | leency | 12 | int GetImageNumber(); |
4486 | leency | 13 | void Images(); |
4491 | leency | 14 | }; |
4486 | leency | 15 | |
4491 | leency | 16 | void ImageCache::Free() |
4411 | leency | 17 | { |
4486 | leency | 18 | for ( ; pics_count>0; pics_count--) |
4411 | leency | 19 | { |
4486 | leency | 20 | if (pics[pics_count].image) img_destroy stdcall (pics[pics_count].image); |
21 | pics[pics_count].path = NULL; |
||
4411 | leency | 22 | } |
23 | } |
||
24 | |||
4544 | leency | 25 | int ImageCache::GetImageNumber(dword i_path) |
4411 | leency | 26 | { |
4486 | leency | 27 | int i; |
4550 | leency | 28 | for (i=0; i<=pics_count; i++) if (!strcmp(#pics[i].path, i_path)) return i; //image exists |
4486 | leency | 29 | // Load image and add it to Cache |
30 | pics_count++; |
||
31 | pics[pics_count].image = load_image(i_path); |
||
32 | strcpy(#pics[pics_count].path, i_path); |
||
33 | return pics_count; |
||
4411 | leency | 34 | } |
35 | |||
36 | |||
4491 | leency | 37 | void ImageCache::Images(int left1, top1, width1) |
4411 | leency | 38 | { |
39 | dword image; |
||
40 | char img_path[4096], alt[4096]; |
||
41 | int w=0, h=0, img_lines_first=0, cur_pic=0; |
||
42 | |||
43 | do{ |
||
44 | if (!strcmp(#parametr,"src=")) //надо объединить с GetNewUrl() |
||
45 | { |
||
4540 | leency | 46 | //if (downloader_id) strcpy(#img_path, #history_list[history_current-1].Item); else |
47 | strcpy(#img_path, BrowserHistory.CurrentUrl()); |
||
4411 | leency | 48 | if (strcmpn(#img_path, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0) |
49 | { |
||
4414 | leency | 50 | //get path: absolute or relative |
51 | if (options[0]=='/') |
||
52 | strcpy(#img_path, #options); |
||
53 | else |
||
54 | { |
||
55 | img_path[strrchr(#img_path, '/')] = '\0'; |
||
56 | strcat(#img_path, #options); |
||
4416 | leency | 57 | } |
4544 | leency | 58 | cur_pic = GetImageNumber(#img_path); |
4411 | leency | 59 | } |
60 | } |
||
4414 | leency | 61 | if (!strcmp(#parametr,"alt=")) |
4411 | leency | 62 | { |
63 | strcpy(#alt, "["); |
||
64 | strcat(#alt, #options); |
||
65 | strcat(#alt, "]"); |
||
66 | } |
||
67 | |||
68 | } while(GetNextParam()); |
||
69 | |||
70 | if (!pics[cur_pic].image) |
||
71 | { |
||
72 | if (alt) && (link) strcat(#line, #alt); |
||
73 | return; |
||
74 | } |
||
75 | |||
76 | w = DSWORD[pics[cur_pic].image+4]; |
||
77 | h = DSWORD[pics[cur_pic].image+8]; |
||
78 | if (w > width1) w = width1; |
||
79 | |||
4414 | leency | 80 | if (stroka==0) DrawBar(WB1.list.x, WB1.list.y, WB1.list.w-15, 5, bg_color); //закрашиваем первую строку |
4486 | leency | 81 | stroka += h/10; |
4414 | leency | 82 | if (top1+h |
83 | if (top1 |
||
4411 | leency | 84 | { |
4414 | leency | 85 | img_lines_first=WB1.list.y-top1; |
4411 | leency | 86 | h=h-img_lines_first; |
4414 | leency | 87 | top1=WB1.list.y; |
4411 | leency | 88 | } |
4414 | leency | 89 | if (top1>WB1.list.y+WB1.list.h-h-5) //если часть изображения снизу |
4411 | leency | 90 | { |
4414 | leency | 91 | h=WB1.list.y+WB1.list.h-top1-5; |
4411 | leency | 92 | } |
93 | if (h<=0) return; |
||
94 | if (anchor) return; |
||
95 | |||
96 | img_draw stdcall (pics[cur_pic].image, left1-5, top1, w, h,0,img_lines_first); |
||
4414 | leency | 97 | DrawBar(left1+w - 5, top1, WB1.list.w-w, h, bg_color); |
4550 | leency | 98 | IF (link) |
99 | { |
||
100 | UnsafeDefineButton(left1 - 5, top1, w, h-1, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9); |
||
101 | PageLinks.AddText(0, w, h-1, NOLINE); |
||
102 | // WB1.DrawPage(); |
||
103 | } |
||
4491 | leency | 104 | } |
105 | |||
106 | ImageCache ImgCache;=0)>=pics_count;> |