/************************** graba_imagen_campo **************************** Función para efectuar la grabación en disco de una imagen del campo. "nombre" es el nombre del archivo a almacenar. "buffer" es el buffer que quiero copiar a disco. ****************************************************************************/ int graba_imagen_campo(char *nombre, MIL_ID buffer) { char nombre_ext[1024], *ext, mensaje[1024], *fn = "graba_imagen_campo"; strcpy(nombre_ext, nombre); // Se copia en nombre_ext el nombre de la imagen a cargar ext = strrchr(nombre_ext, '.'); // Se busca la extensión del fichero que se desea guardar strcpy(nombre_ext, ext+1); // Copiamos el buffer seleccionado en el archivo seleccionado (nombre_ext). if ( strcmp(nombre_ext,"jpg")==0 ) MbufExport(nombre, M_JPEG_LOSSLESS, buffer); if ( strcmp(nombre_ext,"tif")==0 ) { MbufExport(nombre, M_TIFF, buffer); } if ( strcmp(nombre_ext,"mim")==0 ) MbufExport(nombre, M_MIL, buffer); /* Compruebo que no ha habido ningún error durante el proceso de grabación a disco. */ if ( MbufDiskInquire(nombre, M_SIZE_X, M_NULL) == 0) { sprintf(mensaje, "No puedo crear la imagen %s", nombre_ext); printf(mensaje); return 1; } return 0; }
bool MdispGtkView::save(const char *filename) { gboolean SaveStatus; gchar * TempPath; long FileFormat = M_MIL; gchar *tmp; // Get extension for file format determination TempPath = g_ascii_strup(filename,-1); //Set the file format to M_MIL when the filepath extension is ".MIM" if (g_str_has_suffix(TempPath,".MIM")) FileFormat = M_MIL; //Set the file format to M_TIFF when the filepath extension is ".TIF" else if (g_str_has_suffix(TempPath,".TIF")) FileFormat = M_TIFF; //Set the file format to M_BMP when the filepath extension is ".BMP" else if (g_str_has_suffix(TempPath,".BMP")) FileFormat = M_BMP; //Set the file format to M_JPEG_LOSSY when the filepath extension is ".JPG" else if (g_str_has_suffix(TempPath,".JPG")) FileFormat = M_JPEG_LOSSY; //Set the file format to M_JPEG2000_LOSSLESS when the filepath extension is ".JP2" else if (g_str_has_suffix(TempPath,".JP2")) FileFormat = M_JPEG2000_LOSSLESS; //Set the file format to M_RAW when the filepath extension is ".RAW" else if (g_str_has_suffix(TempPath,".RAW")) FileFormat = M_RAW; // Halt the grab if the current view has it [CALL TO MIL] if((((MdispGtkApp*)dispGtkApp())->m_pGrabView == this) && (((MdispGtkApp*)dispGtkApp())->m_isGrabStarted == true)) MdigHalt(((MdispGtkApp*)dispGtkApp())->m_MilDigitizer); // Save the current buffer [CALL TO MIL] tmp = g_strdup(filename); MbufExport(tmp, FileFormat,m_MilImage); g_free(tmp); // Verify if save operation was successful [CALL TO MIL] SaveStatus = (MappGetError(M_CURRENT,M_NULL) == M_NULL_ERROR); // Document has been saved if (!((((MdispGtkApp*)dispGtkApp())->m_pGrabView == this) && (((MdispGtkApp*)dispGtkApp())->m_isGrabStarted == true))) m_Modified = false; // Restart the grab if the current view had it [CALL TO MIL] if((((MdispGtkApp*)dispGtkApp())->m_pGrabView == this) && (((MdispGtkApp*)dispGtkApp())->m_isGrabStarted == true)) MdigGrabContinuous(((MdispGtkApp*)dispGtkApp())->m_MilDigitizer, m_MilImage); return SaveStatus; }
// guarda la imagen rgb en el fichero dado void ControlImagenes::GuardarRGB(CString csNombreFichero) { MbufExport((char*)(LPCTSTR)csNombreFichero,M_TIFF,m_MilRGB); }