Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4973 right-hear 1
#include"libmgfx.h"
2
 
3
int load_image(char * fname,mgfx_image_t ** the_img)
4
{
5
 FILE * f;
6
 struct mgfx_image_format * fmt;
7
 mgfx_image_t * img;
8
 int __ret;
9
 if(!(img=(mgfx_image_t *)malloc(sizeof(mgfx_image_t))))
10
  return _PICERR_NOMEM;
11
 if(!(fmt=get_image_format(fname)))
12
  return _PICERR_UNSUPPORTED;
13
 f=fopen(fname,"rb");
14
 if(!f) return _PICERR_NOFILE;
15
 img->fmt=fmt;
16
 __ret=fmt->load_fn(f,img);
17
 if(__ret==_PIC_OK)
18
 {
19
  *the_img=img;
20
 } else {
21
  *the_img=NULL;
22
  free(img);
23
 }
24
 fclose(f);
25
 return __ret;
26
}
27
 
28
int load_image_f(char * fname,FILE * f,mgfx_image_t ** the_img)
29
{
30
 struct mgfx_image_format * fmt;
31
 mgfx_image_t * img;
32
 int __ret;
33
 if(!(img=(mgfx_image_t *)malloc(sizeof(mgfx_image_t))))
34
  return _PICERR_NOMEM;
35
 if(!(fmt=get_image_format(fname)))
36
  return _PICERR_UNSUPPORTED;
37
 img->fmt=fmt;
38
 __ret=fmt->load_fn(f,img);
39
 if(__ret==_PIC_OK)
40
 {
41
  *the_img=img;
42
 } else {
43
  *the_img=NULL;
44
  free(img);
45
 }
46
 fclose(f);
47
 return __ret;
48
}
49
 
50
void free_image(mgfx_image_t * img)
51
{
52
 if(img)
53
 {
54
  free(img->the_image);
55
 }
56
}
57
 
58
void paint_image(int x,int y,mgfx_image_t * img)
59
{
60
 if(!img || img->bpp!=24) return;
61
 __menuet__putimage(x,y,img->width,img->height,img->the_image);
62
}