TIFF->BMP
Publicado por jose (18 intervenciones) el 15/10/2002 19:31:46
Necesito convertir una imagen TIFF a una BMP, me da igual hacerlo en C o Visual Basic
Valora esta pregunta


0
#include <stdio.h>
#include <tiffio.h>
#include <stdlib.h>
void convertTiffToBmp(const char* tiffFile, const char* bmpFile) {
TIFF* tiff = TIFFOpen(tiffFile, "r");
if (tiff) {
uint32 width, height;
size_t npixels;
uint32* raster;
TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &width);
TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &height);
npixels = width * height;
raster = (uint32*) _TIFFmalloc(npixels * sizeof(uint32));
if (raster != NULL) {
if (TIFFReadRGBAImage(tiff, width, height, raster, 0)) {
FILE* bmp = fopen(bmpFile, "wb");
if (bmp) {
// Escribir encabezado BMP
// (Aquí deberías implementar la escritura del encabezado BMP)
// Escribir los datos de la imagen
fwrite(raster, sizeof(uint32), npixels, bmp);
fclose(bmp);
}
}
_TIFFfree(raster);
}
TIFFClose(tiff);
} else {
printf("Error al abrir el archivo TIFF.\n");
}
}
int main() {
convertTiffToBmp("input.tiff", "output.bmp");
return 0;
}
Imports System.Drawing
Imports System.Drawing.Imaging
Module Module1
Sub Main()
Dim tiffFile As String = "input.tiff"
Dim bmpFile As String = "output.bmp"
Using img As Image = Image.FromFile(tiffFile)
img.Save(bmpFile, ImageFormat.Bmp)
End Using
End Sub
End Module