Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

Image.c

Go to the documentation of this file.
00001 /*
00002  *    gui - [gega user interface] the flexible solution for user interface problems
00003  *    Copyright (C) 2002  Gergely Gati
00004  *
00005  *    This program is free software; you can redistribute it and/or modify
00006  *    it under the terms of the GNU General Public License as published by
00007  *    the Free Software Foundation; version 2 of the License.
00008  *
00009  *    This program is distributed in the hope that it will be useful,
00010  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *    GNU General Public License for more details.
00013  *
00014  *    You should have received a copy of the GNU General Public License
00015  *    along with this program; if not, write to the Free Software
00016  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  *
00018  *    Gergely Gati
00019  *      email:           g.gati@freemail.hu
00020  *      AIM screenname:  GatiGergely
00021  *      ICQ number:      93131690
00022  *
00023  */
00024 #include <stdlib.h>
00025 #include <string.h>
00026 
00027 #define __IMAGE_MODULE
00028 
00029 #include "macros.h"
00030 #include "debug.h"
00031 #include "Memory.h"
00032 #include "Net.h"
00033 #include "Image.h"
00034 #include "Window.h"
00035 
00036 
00037 #define IMG_FS_RECOG   1
00038 #define IMG_FS_LOADED  2
00039 
00040 
00041 struct Format_s
00042 {
00043   char *name;
00044   int status;
00045   int counter;
00046   int (*img_recognize)(u8 *,int);
00047   int (*img_init)(Image_t *,void (*)(void *),void *);
00048   void (*img_clean)(Image_t *);
00049   int (*img_render)(Image_t *,u8 *,int,int,int);
00050   int (*img_putimage)(Image_t *,u32,Rect_t *);
00051   void (*cleanup)(void);
00052   u32 module;
00053   u32 mainmodule;
00054 };
00055 
00056 
00057 static List_t *FormatList;      //SEMAPHORE PROTECTED!
00058 static u32 (*call_vector[IMG_FUNC_DONE-IMG_FUNCBASE+1])(tag *);
00059 
00060 static Image_t *img_InitImageByMem(ImageIn_t *image, void (*update)(void *),void *userdata);
00061 static Image_t *img_InitImageByName(gui_App_t *app, char *name, void (*update)(void *),void *userdata);
00062 
00063 
00070 u32 img_InitImage(u32 firsttag, ...)
00071 {
00072   return(img_InitImageTL((tag *)&firsttag));
00073 }
00074 u32 img_InitImageTL(tag *taglist)
00075 {
00076   gui_App_t *app;
00077 
00078   ImageIn_t *image;
00079   Image_t *img=NULL;
00080   char *imagename;
00081 
00082   debug_Begin();
00083 
00084   app=(gui_App_t *)tag_GetTagData(taglist,TAG_IMG_APP,0L);
00085 
00086   image=(ImageIn_t *)tag_GetTagData(taglist,TAG_IMG_IMAGEIN,0L);
00087   if(image!=NULL)
00088   {
00089     img=img_InitImageByMem(image,NULL,NULL);
00090     img->app=app;
00091     img->free_after_use=(int)tag_GetTagData(taglist,TAG_IMG_FREEAFTERUSE,0L);
00092   }
00093   else
00094   {
00095     imagename=(char *)tag_GetTagData(taglist,TAG_IMG_IMAGENAME,0L);
00096     if(NULL!=imagename) img=img_InitImageByName(app,imagename,NULL,NULL);
00097   }
00098 
00099   debug_End();
00100 
00101   return((u32)img);
00102 }
00103 
00104 
00105 
00106 static Image_t *img_InitImageByMem(ImageIn_t *image, void (*update)(void *),void *userdata)
00107 {
00108   Image_t *img=NULL;
00109   Format_t *format;
00110   Node_t *node;
00111   char *name;
00112 
00113   debug_Begin();
00114 
00115   if(image!=NULL)
00116   {
00117     if(NULL!=(img=mem_malloc(sizeof(Image_t))))
00118     {
00119       memcpy(&img->iim,image,sizeof(ImageIn_t));
00120       img->format=NULL;
00121       for(node=list_GetNodeHead(FormatList);node!=NULL;node=list_GetNodeNext(FormatList,node))
00122       {
00123         format=(Format_t *)list_GetNodeData(node);
00124         if(0==format->img_recognize(image->data,image->data_size))
00125         {
00126           if(format->status!=IMG_FS_LOADED)
00127           {
00128             if(format->status==IMG_FS_RECOG)
00129             {
00130               if(NULL!=(name=mem_malloc(strlen(format->name)+1+6+7+4)))
00131               {
00132                 strcpy(name,"images/");
00133                 strcat(name,format->name);
00134                 strcat(name,".image_mod");
00135                 glw_OpenModule(name);
00136                 mem_free(name);
00137               }
00138             }
00139           }
00140           if(format->img_init!=NULL&&0==(format->img_init(img,update,userdata)))
00141           {
00142             format->counter++;
00143             img->format=format->name;
00144             img->formatpnt=format;
00145             img->free_after_use=0;
00146             break;
00147           }
00148         }
00149       }
00150     }
00151     if(img->format==NULL)
00152     {
00153       mem_free(img);
00154       img=NULL;
00155     }
00156   }
00157 
00158   debug_End();
00159 
00160   return(img);
00161 }
00162 
00163 
00164 static Image_t *img_InitImageByName(gui_App_t *app, char *name, void (*update)(void *),void *userdata)
00165 {
00166   Image_t *img=NULL;
00167   ImageIn_t image;
00168 
00169   debug_Begin();
00170 
00171   // get_file_handle (appname/prefs/name)
00172   if(NULL!=(image.data=(u8 *)net_LoadFile(TAG_NET_CONN,app->conn,TAG_NET_NAME,name,TAG_NET_LEN,&image.data_size,TAG_DONE)))
00173   {
00174     if(NULL!=(img=img_InitImageByMem(&image,update,userdata)))
00175     {
00176       debug_Message("--name='%s' id=%p",name,img);
00177       img->app=app;
00178       img->free_after_use=1;
00179     }
00180   }
00181 
00182   debug_End();
00183 
00184   return(img);
00185 }
00186 
00187 
00188 u32 img_CleanUpImage(u32 firsttag, ...)
00189 {
00190   return(img_CleanUpImageTL((tag *)&firsttag));
00191 }
00192 u32 img_CleanUpImageTL(tag *taglist)
00193 {
00194   Image_t *img;
00195 
00196   int ret=-1;
00197   Format_t *format;
00198 
00199 
00200   debug_Begin();
00201 
00202   img=(Image_t *)tag_GetTagData(taglist,TAG_IMG_OBJECT,0L);
00203 
00204   if(img!=NULL)
00205   {
00206     if(NULL!=(format=img->formatpnt))
00207     {
00208       format->img_clean(img);
00209       format->counter--;
00210       if(format->counter==0&&format->mainmodule!=0L)
00211       {
00212         format->status=IMG_FS_RECOG;
00213         glw_CloseModule(format->mainmodule);
00214         format->mainmodule=0L;
00215         format->img_init=NULL;
00216         format->img_clean=NULL;
00217         format->img_render=NULL;
00218         format->img_putimage=NULL;
00219         format->cleanup=NULL;
00220       }
00221       img->formatdata=NULL;
00222       img->formatpnt=NULL;
00223     }
00224     if(img->free_after_use!=0) mem_free(img->iim.data);
00225     mem_free(img);
00226   }
00227 
00228   debug_End();
00229 
00230   return((u32)ret);
00231 }
00232 
00233 
00237 u32 img_GetInfo(u32 firsttag, ...)
00238 {
00239   return(img_GetInfoTL((tag *)&firsttag));
00240 }
00241 u32 img_GetInfoTL(tag *taglist)
00242 {
00243   Image_t *img;
00244   ImageInfo_t *imginfo;
00245 
00246   int ret=-1;
00247 
00248 
00249   debug_Begin();
00250 
00251   img=(Image_t *)tag_GetTagData(taglist,TAG_IMG_OBJECT,0L);
00252   imginfo=(ImageInfo_t *)tag_GetTagData(taglist,TAG_IMG_IMGINFO,0L);
00253 
00254   if(NULL!=img&&NULL!=imginfo)
00255   {
00256     debug_Message("--id=%p",img);
00257     memcpy(&imginfo->iim,&img->iim,sizeof(ImageIn_t));
00258     imginfo->format=img->format;
00259     imginfo->minwidth=img->minwidth;
00260     imginfo->maxwidth=img->maxwidth;
00261     imginfo->minheight=img->minheight;
00262     imginfo->maxheight=img->maxheight;
00263     ret=0;
00264   }
00265 
00266   debug_End();
00267 
00268   return((u32)ret);
00269 }
00270 
00271 
00278 u32 img_RenderImage(u32 firsttag, ...)
00279 {
00280   return(img_RenderImageTL((tag *)&firsttag));
00281 }
00282 u32 img_RenderImageTL(tag *taglist)
00283 {
00284   Image_t *img;
00285   u8 *dest;
00286   int destsize;
00287   int width;
00288   int height;
00289 
00290   int ret=-1;
00291   Format_t *format;
00292 
00293 
00294   debug_Begin();
00295 
00296   img=(Image_t *)tag_GetTagData(taglist,TAG_IMG_OBJECT,0L);
00297   dest=(u8 *)tag_GetTagData(taglist,TAG_IMG_DEST,0L);
00298   destsize=(int )tag_GetTagData(taglist,TAG_IMG_DESTSIZE,0L);
00299   width=(int )tag_GetTagData(taglist,TAG_IMG_WIDTH,0L);
00300   height=(int )tag_GetTagData(taglist,TAG_IMG_HEIGHT,0L);
00301 
00302   if(img!=NULL)
00303   {
00304     debug_Message("--id=%p",img);
00305     if(NULL!=(format=img->formatpnt))
00306     {
00307       if(img->minwidth<=width&&img->minheight<=height&&img->maxwidth>=width&&img->maxheight>=height)
00308       {
00309         if(0==(format->img_render(img,dest,destsize,width,height))) ret=0;
00310       }
00311     }
00312   }
00313 
00314   debug_End();
00315 
00316   return((u32)ret);
00317 }
00318 
00319 
00324 u32 img_PutImage(u32 firsttag, ...)
00325 {
00326   return(img_PutImageTL((tag *)&firsttag));
00327 }
00328 u32 img_PutImageTL(tag *taglist)
00329 {
00330   Image_t *img;
00331   Window_t *win;
00332   Rect_t *rect;
00333 
00334   int ret=-1;
00335   Format_t *format;
00336 
00337 
00338   debug_Begin();
00339 
00340   img=(Image_t *)tag_GetTagData(taglist,TAG_IMG_OBJECT,0L);
00341   win=(Window_t *)tag_GetTagData(taglist,TAG_IMG_WINDOW,0L);
00342   rect=(Rect_t *)tag_GetTagData(taglist,TAG_IMG_RECT,0L);
00343 
00344   if(img!=NULL)
00345   {
00346     debug_Message("--id=%p",img);
00347     if(NULL!=(format=img->formatpnt))
00348     {
00349       debug_Message("rect: %dx%d :: img min: %dx%d  max: %dx%d",rect->width,rect->height,img->minwidth,img->minheight,img->maxwidth,img->maxheight);
00350       if( img->minwidth<=rect->width&&
00351           img->minheight<=rect->height&&
00352           img->maxwidth>=rect->width&&
00353           img->maxheight>=rect->height)
00354       {
00355         debug_Trace();
00356         if(0==(format->img_putimage(img,win->handle,rect))) ret=0;
00357         debug_Trace();
00358       }
00359     }
00360   }
00361 
00362   debug_End();
00363 
00364   return((u32)ret);
00365 }
00366 
00367 
00376 u32 img_RenderImageTiled(u32 firsttag, ...)
00377 {
00378   return(img_RenderImageTiledTL((tag *)&firsttag));
00379 }
00380 u32 img_RenderImageTiledTL(tag *taglist)
00381 {
00382   Image_t *img;
00383   u8 *dest;
00384   int destsize;
00385   int imgwidth;
00386   int imgheight;
00387   int width;
00388   int height;
00389 
00390   int ret=-1;
00391   u8 *buf,*pnt,*from;
00392   int buflen,vn,hn,vp,hp,top,left=0,x,y,i,lastleft;
00393   Format_t *format;
00394 
00395 
00396   debug_Begin();
00397 
00398   img=(Image_t *)tag_GetTagData(taglist,TAG_IMG_OBJECT,0L);
00399   dest=(u8 *)tag_GetTagData(taglist,TAG_IMG_DEST,0L);
00400   destsize=(int )tag_GetTagData(taglist,TAG_IMG_DESTSIZE,0L);
00401   imgwidth=(int )tag_GetTagData(taglist,TAG_IMG_IMGWIDTH,0L);
00402   imgheight=(int )tag_GetTagData(taglist,TAG_IMG_IMGHEIGHT,0L);
00403   width=(int )tag_GetTagData(taglist,TAG_IMG_WIDTH,0L);
00404   height=(int )tag_GetTagData(taglist,TAG_IMG_HEIGHT,0L);
00405 
00406   ret=0;
00407   if(img!=NULL)
00408   {
00409     debug_Message("--id=%p",img);
00410     if(NULL!=(format=img->formatpnt))
00411     {
00412       if(img->minwidth<=imgwidth&&img->minheight<=imgheight&&img->maxwidth>=imgwidth&&img->maxheight>=imgheight)
00413       {
00414         buflen=imgwidth*imgheight*4;
00415         if(NULL!=(buf=mem_malloc(buflen)))
00416         {
00417           if(0==(format->img_render(img,buf,buflen,imgwidth,imgheight)))
00418           {
00419             memset(dest,0,destsize);
00420             hn=width/imgwidth;
00421             hp=width%imgwidth;
00422             vn=height/imgheight;
00423             vp=height%imgheight;
00424             for(top=y=0;y<vn;y++,top+=(width*4)*imgheight)
00425             {
00426               for(left=x=0;x<hn;x++,left+=imgwidth)
00427               {
00428                 pnt=dest+((top)+left*4);
00429                 from=buf;
00430                 for(i=0;i<imgheight;i++,pnt+=width*4,from+=imgwidth*4)
00431                 {
00432                   memcpy(pnt,from,imgwidth*4);
00433                 }
00434               }
00435             }
00436             // a teljes kepek keszen vannak, jojjenek a hianyosak (elobb az also)
00437             lastleft=left;
00438             for(left=x=0;x<hn;x++,left+=imgwidth)
00439             {
00440               pnt=dest+((top)+left*4);
00441               from=buf;
00442               for(i=0;i<vp;i++,pnt+=width*4,from+=imgwidth*4)
00443               {
00444                 memcpy(pnt,from,imgwidth*4);
00445               }
00446             }
00447             // aztan a jobb oldalon
00448             for(top=y=0,left=lastleft;y<vn;y++,top+=(width*4)*imgheight)
00449             {
00450               pnt=dest+((top)+left*4);
00451               from=buf;
00452               for(i=0;i<imgheight;i++,pnt+=width*4,from+=imgwidth*4)
00453               {
00454                 memcpy(pnt,from,hp*4);
00455               }
00456             }
00457             // vegul az utolso a sarokban
00458             left=imgwidth*hn;
00459             top=((width*4)*imgheight)*vn;
00460             pnt=dest+((top)+left*4);
00461             from=buf;
00462             for(i=0;i<vp;i++,pnt+=width*4,from+=imgwidth*4)
00463             {
00464               memcpy(pnt,from,hp*4);
00465             }
00466           }
00467           mem_free(buf);
00468         }
00469       }
00470     }
00471   }
00472 
00473   debug_End();
00474 
00475   return((u32)ret);
00476 }
00477 
00478 
00485 u32 img_PutImageTiled(u32 firsttag, ...)
00486 {
00487   return(img_PutImageTiledTL((tag *)&firsttag));
00488 }
00489 u32 img_PutImageTiledTL(tag *taglist)
00490 {
00491   Image_t *img;
00492   Window_t *win;
00493   int imgwidth;
00494   int imgheight;
00495   Rect_t *rect;
00496 
00497   int ret=-1;
00498   Format_t *format;
00499   Vector_t dest;
00500 
00501   debug_Begin();
00502 
00503   img=(Image_t *)tag_GetTagData(taglist,TAG_IMG_OBJECT,0L);
00504   win=(Window_t *)tag_GetTagData(taglist,TAG_IMG_WINDOW,0L);
00505   imgwidth=(int )tag_GetTagData(taglist,TAG_IMG_IMGWIDTH,0L);
00506   imgheight=(int )tag_GetTagData(taglist,TAG_IMG_IMGHEIGHT,0L);
00507   rect=(Rect_t *)tag_GetTagData(taglist,TAG_IMG_RECT,0L);
00508 
00509   if(img!=NULL&&NULL!=(format=img->formatpnt))
00510   {
00511     debug_Message("--id=%p",img);
00512     if(img->minwidth<=imgwidth&&img->minheight<=imgheight&&img->maxwidth>=imgwidth&&img->maxheight>=imgheight)
00513     {
00514       dest.size=rect->width*rect->height*4;
00515       if(NULL!=(dest.data=mem_malloc(dest.size)))
00516       {
00517         if(0==(img_RenderImageTiled(TAG_IMG_OBJECT,img,
00518                                     TAG_IMG_DEST,dest.data,
00519                                     TAG_IMG_DESTSIZE,dest.size,
00520                                     TAG_IMG_IMGWIDTH,imgwidth,
00521                                     TAG_IMG_IMGHEIGHT,imgheight,
00522                                     TAG_IMG_WIDTH,rect->width,
00523                                     TAG_IMG_HEIGHT,rect->height,
00524                                     TAG_DONE)))
00525         {
00526           ret=glw_PutImage(TAG_GLW_WINDOW,win->handle,TAG_GLW_PIXELS,&dest,TAG_GLW_CLIPRECT,rect,TAG_GLW_LEFT,rect->left,TAG_GLW_TOP,rect->top,TAG_GLW_WIDTH,rect->width,TAG_GLW_HEIGHT,rect->height,TAG_DONE);
00527         }
00528         mem_free(dest.data);
00529       }
00530     }
00531   }
00532 
00533   debug_End();
00534 
00535   return((u32)ret);
00536 }
00537 
00538 
00548 u32 img_RegisterFormatCode(u32 firsttag, ...)
00549 {
00550   return(img_RegisterFormatCodeTL((tag *)&firsttag));
00551 }
00552 u32 img_RegisterFormatCodeTL(tag *taglist)
00553 {
00554   char *name;
00555   int (*img_init)(Image_t *,void (*)(void *),void *);
00556   int (*img_render)(Image_t *,u8 *,int,int,int);
00557   int (*img_putimage)(Image_t *,u32 window,Rect_t *);
00558   void (*img_clean)(Image_t *);
00559   void (*cleanup)(void);
00560   u32 module;
00561 
00562   int ret=-1;
00563   Format_t *format;
00564   Node_t *node;
00565 
00566   name=(char *)tag_GetTagData(taglist,TAG_IMG_NAME,0L);
00567   img_init=(int (*)(Image_t *,void (*)(void *),void *))tag_GetTagData(taglist,TAG_IMG_IMG_INIT,0L);
00568   img_render=(int (*)(Image_t *,u8 *,int,int,int))tag_GetTagData(taglist,TAG_IMG_IMG_RENDER,0L);
00569   img_putimage=(int (*)(Image_t *,u32 window,Rect_t *))tag_GetTagData(taglist,TAG_IMG_IMG_PUTIMAGE,0L);
00570   img_clean=(void (*)(Image_t *))tag_GetTagData(taglist,TAG_IMG_IMG_CLEAN,0L);
00571   cleanup=(void (*)(void))tag_GetTagData(taglist,TAG_IMG_CLEANUP,0L);
00572   module=(u32)tag_GetTagData(taglist,TAG_IMG_MODULE,0L);
00573 
00574   debug_Begin();
00575 
00576   if(name!=NULL&&img_init!=NULL&&img_render!=NULL&&img_putimage!=NULL&&img_clean!=NULL)
00577   {
00578     for(node=list_GetNodeHead(FormatList);node!=NULL;node=list_GetNodeNext(FormatList,node))
00579     {
00580       if(NULL!=(format=(Format_t *)list_GetNodeData(node)))
00581       {
00582         if(strcmp(format->name,name)==0)
00583         {
00584           format->status=IMG_FS_LOADED;
00585           format->img_init=img_init;
00586           format->img_clean=img_clean;
00587           format->img_render=img_render;
00588           format->img_putimage=img_putimage;
00589           format->cleanup=cleanup;
00590           format->mainmodule=module;
00591           ret=0;
00592         }
00593       }
00594     }
00595   }
00596 
00597   debug_End();
00598 
00599   return((u32)ret);
00600 }
00601 
00602 
00608 u32 img_RegisterFormat(u32 firsttag, ...)
00609 {
00610   return(img_RegisterFormatTL((tag *)&firsttag));
00611 }
00612 u32 img_RegisterFormatTL(tag *taglist)
00613 {
00614   char *name;
00615   int (*img_recognize)(u8 *,int);
00616   u32 module;
00617 
00618   int ret=-1;
00619   Format_t *format;
00620   Node_t *node;
00621 
00622   name=(char *)tag_GetTagData(taglist,TAG_IMG_NAME,0L);
00623   img_recognize=(int (*)(u8 *,int))tag_GetTagData(taglist,TAG_IMG_IMG_RECOGNIZE,0L);
00624   module=(u32)tag_GetTagData(taglist,TAG_IMG_MODULE,0L);
00625 
00626   debug_Begin();
00627 
00628   if(img_recognize!=NULL&&NULL!=(format=mem_malloc(sizeof(Format_t))))
00629   {
00630     if(NULL!=(node=list_CreateNode()))
00631     {
00632       format->status=IMG_FS_RECOG;
00633       format->name=name;
00634       format->counter=0;
00635       format->img_recognize=img_recognize;
00636       format->module=module;
00637       format->mainmodule=0L;
00638       list_SetNodeData(node,format);
00639       list_InsertNodeTail(FormatList,node);
00640       ret=0;
00641     }
00642   }
00643 
00644   debug_End();
00645 
00646   return((u32)ret);
00647 }
00648 
00649 
00650 void img_CleanUp(void)
00651 {
00652   Node_t *node;
00653   Format_t *format;
00654 
00655   debug_Begin();
00656 
00657   if(FormatList!=NULL)
00658   {
00659     for(node=list_GetNodeHead(FormatList);node!=NULL;node=list_GetNodeHead(FormatList))
00660     {
00661       list_RemoveNode(FormatList,node);
00662       if(NULL!=(format=(Format_t *)list_GetNodeData(node)))
00663       {
00664         debug_Message("free format: '%s'",format->name);
00665         list_DeleteNode(node);
00666         debug_Trace();
00667         if(format->status==IMG_FS_LOADED)
00668         {
00669           if(format->cleanup!=NULL) format->cleanup();
00670           debug_Trace();
00671           glw_CloseModule(format->mainmodule);
00672           debug_Trace();
00673         }
00674         glw_CloseModule(format->module);
00675         debug_Trace();
00676         mem_free(format);
00677         debug_Message("format free finished.");
00678       }
00679     }
00680     list_DeleteList(FormatList);
00681   }
00682   FormatList=NULL;
00683 
00684   debug_End();
00685 }
00686 
00687 
00688 int img_Init(void)
00689 {
00690   int ret=0;
00691   glw_Dir_t *dir;
00692 
00693   debug_Begin();
00694 
00695   call_vector[IMG_INITIMAGE-IMG_FUNCBASE]=img_InitImageTL;
00696   call_vector[IMG_RENDERIMAGE-IMG_FUNCBASE]=img_RenderImageTL;
00697   call_vector[IMG_PUTIMAGE-IMG_FUNCBASE]=img_PutImageTL;
00698   call_vector[IMG_RENDERIMAGETILED-IMG_FUNCBASE]=img_RenderImageTiledTL;
00699   call_vector[IMG_PUTIMAGETILED-IMG_FUNCBASE]=img_PutImageTiledTL;
00700   call_vector[IMG_CLEANUPIMAGE-IMG_FUNCBASE]=img_CleanUpImageTL;
00701   call_vector[IMG_GETINFO-IMG_FUNCBASE]=img_GetInfoTL;
00702   call_vector[IMG_REGISTERFORMAT-IMG_FUNCBASE]=img_RegisterFormatTL;
00703   call_vector[IMG_REGISTERFORMATCODE-IMG_FUNCBASE]=img_RegisterFormatCodeTL;
00704   bases_modules.img_Call=img_Call;
00705   bases_modules.img_CallTL=img_CallTL;
00706 
00707   if(NULL!=(FormatList=list_CreateList()))
00708   {
00709     /*
00710      *  Ide majd kell egy kis rutin, ami a module directory-bol (dir a prefsbol)
00711      *  kiolvassa (glw+=dir olvaso fuggvenyek!) az osszes file-t aminek *.image_id
00712      *  a neve es mindre meghivja az OpenModule()-t.
00713      */
00714     if(0L!=(dir=glw_DirOpen("images")))
00715     {
00716       char *fname=NULL,*mname=NULL;
00717       for(fname=glw_DirNext(dir);fname!=NULL;fname=glw_DirNext(dir))
00718       {
00719         debug_Message("New module found: '%s'",fname);
00720         if(strstr(fname,".image_id")!=NULL)
00721         {
00722           if(NULL!=(mname=mem_malloc(strlen(fname)+1+7)))
00723           {
00724             strcpy(mname,"images/");
00725             strcat(mname,fname);
00726             debug_Message("  Load it! '%s'",mname);
00727             glw_OpenModule(mname);
00728             mem_free(mname);
00729           }
00730         }
00731         mem_free(fname);
00732         fname=NULL;
00733       }
00734       glw_DirClose(dir);
00735     }
00736   }
00737 
00738   debug_End();
00739 
00740   return(ret);
00741 }
00742 
00743 
00744 u32 img_Call(int function, u32 firsttag, ...)
00745 {
00746   return(img_CallTL(function,(tag *)&firsttag));
00747 }
00748 u32 img_CallTL(int function, tag *taglist)
00749 {
00750   u32 ret=~0L;
00751 
00752   debug_Begin();
00753 
00754   debug_Message("function ID : %d",function-IMG_FUNCBASE);
00755 
00756   if(function>=IMG_FUNCBASE&&function<IMG_FUNC_DONE)
00757   {
00758     ret=call_vector[function-IMG_FUNCBASE](taglist);
00759   }
00760   else debug_Warning("%s(): Function code out of range! code=0x%04x",__FUNCTION__,function);
00761 
00762 
00763   debug_End();
00764 
00765   return(ret);
00766 }

Generated on Tue Jan 7 12:11:22 2003 for THEGUI by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002