User:AtteSmythe/yppRAW/yppRAW.c

/* yppRAW.c * Version 0.01 * This is a File input and output filter for the * GIMP. It loads images in the RAW format used by * Three Rings Design's "Yo ho ho! Puzzle Pirates!" * * Some Parts that deal with the interaction with * the GIMP are taken from the BMP plugin by * Alexander Schulz, who in turn borrowed from the * GIF plugin by Peter Mattis & SPencer Kimball, * and from the PCX plugin by Francisco Bustamante * * I didn't look at their stuff, so I don't know * if I'm using it or not. * * atteSmythe@black-opal.org - 10 Aug 2005 * */

/* * The GIMP -- an image manipulation program * Copyright (C) 1995 Spencer Kimball and Peter Mattis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */


 * 1) include "config.h"


 * 1) include 
 * 2) include 
 * 3) include 


 * 1) include 


 * 1) include 
 * 2) include 


 * 1) include "yppRAW.h"


 * 1) include "libgimp/stdplugins-intl.h"

const gchar *filename = NULL;

/* Declare some local functions. */ static void  query (void); static void  run   (const gchar      *name,                     gint              nparams,                     const GimpParam  *param,                     gint             *nreturn_vals,                     GimpParam       **return_vals);

GimpPlugInInfo PLUG_IN_INFO = { NULL,  /* init_proc  */ NULL, /* quit_proc  */ query, /* query_proc */ run,  /* run_proc   */ };

MAIN

static void query (void) { static GimpParamDef load_args[] = {   { GIMP_PDB_INT32,    "run_mode",     "Interactive, non-interactive" }, { GIMP_PDB_STRING,  "filename",     "The name of the file to load" }, { GIMP_PDB_STRING,  "raw_filename", "The name entered" }, }; static GimpParamDef load_return_vals[] = {   { GIMP_PDB_IMAGE, "image", "Output image" }, };

gimp_install_procedure ("file_raw_load",                         "Loads files of Three Rings Design's RAW file format",                          "Loads files of Three Rings Design's RAW file format",                          "Stephen atte Smythe",                          "Jason M. Wisnieski",                          "2004",                          "/RAW",                          NULL,                          GIMP_PLUGIN,                          G_N_ELEMENTS (load_args),                          G_N_ELEMENTS (load_return_vals),                          load_args, load_return_vals);

gimp_register_load_handler ("file_raw_load",				   "raw",				    ""); }

static void run (const gchar     *name,     gint             nparams,     const GimpParam  *param,     gint             *nreturn_vals,     GimpParam       **return_vals) { static GimpParam  values[2]; GimpRunMode      run_mode; GimpPDBStatusType status = GIMP_PDB_SUCCESS; gint32           image_ID; run_mode = param[0].data.d_int32; INIT_I18N ; *nreturn_vals = 1; *return_vals = values; values[0].type         = GIMP_PDB_STATUS; values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR; if (strcmp (name, "file_raw_load") == 0) {   switch (run_mode) {   case GIMP_RUN_INTERACTIVE: break; case GIMP_RUN_NONINTERACTIVE: /* Make sure all the arguments are there! */     if (nparams != 3) status = GIMP_PDB_CALLING_ERROR; break; default: break; }   if (status == GIMP_PDB_SUCCESS) {     image_ID = ReadRAW (param[1].data.d_string); if (image_ID != -1) {       *nreturn_vals = 2; values[1].type        = GIMP_PDB_IMAGE; values[1].data.d_image = image_ID; }     else {       status = GIMP_PDB_EXECUTION_ERROR; }   }  }  else {   status = GIMP_PDB_CALLING_ERROR; } values[0].data.d_status = status; }