int fixit (char * zFilenameI, char * zFilenameO) { userdatap pMydata; mng_retcode iRC; /* get a data buffer */ pMydata = (userdatap)calloc (1, sizeof (userdata)); if (pMydata == NULL) /* oke ? */ { fprintf (stderr, "Cannot allocate a data buffer.\n"); return 1; } pMydata->hFileO = 0; /* initialize some stuff! */ pMydata->hHandleI = MNG_NULL; pMydata->hHandleO = MNG_NULL; pMydata->bHasSAVE = MNG_FALSE; pMydata->bHasTERM = MNG_FALSE; pMydata->bIsJASC = MNG_TRUE; pMydata->iLastchunk = MNG_UINT_HUH; pMydata->iTermaction = 0; pMydata->iIteraction = 0; pMydata->iDelay = 0; pMydata->iItermax = 0; /* can we open the input file ? */ if ((pMydata->hFileI = fopen (zFilenameI, "rb")) == NULL) { /* error out if we can't */ fprintf (stderr, "Cannot open input file %s.\n", zFilenameI); return 1; } /* let's initialize the library */ pMydata->hHandleI = mng_initialize ((mng_ptr)pMydata, myalloc, myfree, MNG_NULL); if (!pMydata->hHandleI) /* did that work out ? */ { fprintf (stderr, "Cannot initialize libmng.\n"); iRC = 1; } else { /* some informatory messages */ fprintf (stderr, "Compiled with libmng %s.\n", MNG_VERSION_TEXT); fprintf (stderr, "Running with libmng %s.\n", mng_version_text()); /* setup callbacks */ if ( ((iRC = mng_setcb_openstream (pMydata->hHandleI, myopenstream )) != 0) || ((iRC = mng_setcb_closestream (pMydata->hHandleI, myclosestream )) != 0) || ((iRC = mng_setcb_readdata (pMydata->hHandleI, myreaddata )) != 0) || ((iRC = mng_setcb_errorproc (pMydata->hHandleI, myprocesserror)) != 0) ) fprintf (stderr, "Cannot set callbacks for libmng.\n"); else { /* reaad the file into memory */ if ((iRC = mng_read (pMydata->hHandleI)) != 0) fprintf (stderr, "Cannot read the input file.\n"); else { /* run through the chunk list to get TERM */ if ((iRC = mng_iterate_chunks (pMydata->hHandleI, 0, myiterchunk)) != 0) fprintf (stderr, "Cannot iterate the chunks.\n"); else { if (pMydata->iError) /* did the iteration fail somehow ? */ iRC = pMydata->iError; else { /* can we open the output file ? */ if ((pMydata->hFileO = fopen (zFilenameO, "wb")) == NULL) { /* error out if we can't */ fprintf (stderr, "Cannot open output file %s.\n", zFilenameO); iRC = 1; } else { /* let's initialize the library */ pMydata->hHandleO = mng_initialize ((mng_ptr)pMydata, myalloc, myfree, MNG_NULL); if (!pMydata->hHandleO) /* did that work out ? */ { fprintf (stderr, "Cannot initialize libmng.\n"); iRC = 1; } else { /* setup callbacks */ if ( ((iRC = mng_setcb_openstream (pMydata->hHandleO, myopenstream )) != 0) || ((iRC = mng_setcb_closestream (pMydata->hHandleO, myclosestream)) != 0) || ((iRC = mng_setcb_writedata (pMydata->hHandleO, mywritedata )) != 0) ) fprintf (stderr, "Cannot set callbacks for libmng.\n"); else { if ((iRC = mng_create (pMydata->hHandleO)) != 0) fprintf (stderr, "Cannot create a new MNG.\n"); else { /* run through the chunk again and create the new file */ if ((iRC = mng_iterate_chunks (pMydata->hHandleI, 0, myiterchunk)) != 0) fprintf (stderr, "Cannot iterate the chunks.\n"); else { /* did the iteration fail somehow ? */ if (pMydata->iError) iRC = pMydata->iError; else { /* now write the created new file !! */ if ((iRC = mng_write (pMydata->hHandleO)) != 0) fprintf (stderr, "Cannot write the output file.\n"); } } } } /* cleanup the library */ mng_cleanup (&pMydata->hHandleO); } /* cleanup output file */ fclose (pMydata->hFileO); } } } } } mng_cleanup (&pMydata->hHandleI); /* cleanup the library */ } fclose (pMydata->hFileI); /* cleanup input file and userdata */ free (pMydata); return iRC; }
int main (int argc, char ** argv) { GtkMngView * mng_view; GtkWidget * window; GtkWidget * align; GtkWidget * frame; guchar * mng_data = NULL; guint mng_data_size; if (argc < 2) { g_print ("Usage: %s <file.mng>\n\n", argv[0]); g_print (" Compiled with GTK+ %d.%d.%d; using GTK+ %d.%d.%d.\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION, gtk_major_version, gtk_minor_version, gtk_micro_version); #ifdef GDK_PIXBUF_VERSION g_print (" Compiled with gdk-pixbuf %s; using gdk-pixbuf %s.\n", GDK_PIXBUF_VERSION, gdk_pixbuf_version); #endif g_print (" Compiled with libmng %s; using libmng %s.\n", MNG_VERSION_TEXT, mng_version_text()); g_print (" Compiled with zlib %s; using zlib %s.\n", ZLIB_VERSION, zlib_version); #ifdef JPEG_LIB_VERSION { int major = JPEG_LIB_VERSION / 10; int minor = JPEG_LIB_VERSION % 10; char minoralpha[2]; if (minor) { minoralpha[0] = (char)(minor - 1 + 'a'); minoralpha[1] = '\0'; } else minoralpha[0] = '\0'; g_print (" Compiled with libjpeg %d%s.\n", major, minoralpha); } #endif g_print ("\nPress Esc or Q, or click mouse button, to quit.\n"); return 1; } mng_data_size = read_file (* (argv + 1), &mng_data); if (mng_data == NULL) return 1; gtk_init (&argc, &argv); gdk_rgb_set_verbose (TRUE); window = gtk_widget_new (GTK_TYPE_WINDOW, "GtkWindow::type", GTK_WINDOW_TOPLEVEL, "GtkWindow::title", "MNG animation", "GtkContainer::border_width", 5, NULL); g_signal_connect (GTK_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (GTK_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); /* any keypress (e.g., Esc or Q) or mouse-button click will quit viewer */ g_signal_connect (GTK_OBJECT (window), "key_press_event", G_CALLBACK (gtk_main_quit), NULL); gtk_widget_add_events(window, GDK_BUTTON_PRESS_MASK); g_signal_connect (GTK_OBJECT (window), "button_press_event", G_CALLBACK (gtk_main_quit), NULL); align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); gtk_container_add (GTK_CONTAINER (window), align); frame = gtk_frame_new (NULL); gtk_container_add (GTK_CONTAINER (align), frame); /* actually it */ mng_view = GTK_MNG_VIEW (gtk_mng_view_new ()); gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (mng_view)); gtk_mng_view_load_mng_from_memory (mng_view, mng_data, mng_data_size); g_free (mng_data); /* rest in piece */ gtk_widget_show_all (window); gtk_main (); return 0; }
static LRESULT CALLBACK DlgProcAbout(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { char buf[4096],buf2[1024],buf3[300]; switch(Msg) { case WM_INITDIALOG: { //DWORD tabs[1]; PluginInstance *This=(PluginInstance*)lParam; //tabs[0]= 60; //SendDlgItemMessage(hWnd,IDC_IMGINFO,EM_SETTABSTOPS,(WPARAM)1,(LPARAM)tabs); wsprintf(buf,"MNGPLG Plug-in, Version %s\r\n%s" #ifdef _DEBUG " DEBUG BUILD" #endif "\r\nCopyright (C) 2000-2002 by Jason Summers\r\n\r\n",MNGPLGVERS,__DATE__); wsprintf(buf2,"Based on libmng by Gerard Juyn.\r\n"); lstrcat(buf,buf2); wsprintf(buf2,"libmng version: %s\r\n\r\n",mng_version_text()); lstrcat(buf,buf2); wsprintf(buf2,"Uses the zlib compression library.\r\n"); lstrcat(buf,buf2); wsprintf(buf2,"zlib version: %s\r\n\r\n",zlibVersion()); lstrcat(buf,buf2); wsprintf(buf2,"This software is based in part on the work of the " "Independent JPEG Group.\r\n"); lstrcat(buf,buf2); // This really only gives the version of the libjpeg header used when // compiling this plugin, but I don't know how to query libjpeg for its // version. wsprintf(buf2,"IJG JPEG library version: %s\r\n%s\r\n\r\n",JVERSION,JCOPYRIGHT); lstrcat(buf,buf2); #ifdef MNGPLG_CMS wsprintf(buf2,"Uses the lcms color management library by Martà Maria. " "lcms is distributed under the terms of the GNU LESSER GENERAL PUBLIC LICENSE. " "See the file COPYING-LCMS.\r\n\r\n"); lstrcat(buf,buf2); #endif if(GetModuleFileName(g_hInst,buf3,260)) { wsprintf(buf2,"MNGPLG location: %s\r\n",buf3); lstrcat(buf,buf2); } SetDlgItemText(hWnd,IDC_PRGINFO,buf); } return(TRUE); case WM_CLOSE: EndDialog(hWnd,0); return(TRUE); case WM_COMMAND: switch(wParam) { case IDOK: case IDCANCEL: EndDialog(hWnd,0); return(TRUE); } } return(FALSE); }