Home   Artículos   Recursos   Foros   
Artíclos recientes publicados en Latindevelopers:

Visual C++: NSDoubleEdit: Un control para el manejo de números decimales en Visual C++.
Visual C++: Implementando una Calculadora en Visual C++
Visual C++: CCommandLine: Una clase para el uso de la linea de comando
Visual C++: Una clase para el manejo del Registro


Imagenes como ??

Aqui programadores en la plataforma Win32 con Visual C++ de Microsoft...

Moderador: latindeveloper

Imagenes como ??

Notapor Isack el Jue Feb 02, 2006 1:49 pm

Hola a todos mi problema que tengo es que cuando quiero guardar una imagen de bmp esta se guarda invertido este es el codigo que utilizo


BOOL CDXCaptureDlg::SaveBMP(BYTE *Buffer, int width, int height, long paddedsize, char *bmpfile)
{
// declare bmp structures
BITMAPFILEHEADER bmfh;
BITMAPINFOHEADER info;

// andinitialize them to zero
memset ( &bmfh, 0, sizeof (BITMAPFILEHEADER ) );
memset ( &info, 0, sizeof (BITMAPINFOHEADER ) );

// fill the fileheader with data
bmfh.bfType = 0x4d42; // 0x4d42 = 'BM'
bmfh.bfReserved1 = 0;
bmfh.bfReserved2 = 0;
bmfh.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + paddedsize;
bmfh.bfOffBits = 0x36; // number of bytes to start of bitmap bits

// fill the infoheader

info.biSize = sizeof(BITMAPINFOHEADER);
info.biWidth = width;
info.biHeight = height;
info.biPlanes = 1; // we only have one bitplane
info.biBitCount = 24; // RGB mode is 24 bits
info.biCompression = BI_RGB;
info.biSizeImage = 0; // can be 0 for 24 bit images
info.biXPelsPerMeter = 0x0ec4; // paint and PSP use this values
info.biYPelsPerMeter = 0x0ec4;
info.biClrUsed = 0; // we are in RGB mode and have no palette
info.biClrImportant = 0; // all colors are important


// now we open the file to write to
HANDLE file = CreateFile ( bmpfile , GENERIC_WRITE, FILE_SHARE_READ,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );

if ( file == NULL )
{
CloseHandle ( file );
return FALSE;
}

// write file header
unsigned long bwritten;
if ( WriteFile ( file, &bmfh, sizeof ( BITMAPFILEHEADER ), &bwritten, NULL ) == FALSE )
{
CloseHandle ( file );
return FALSE;
}

// write infoheader
if ( WriteFile ( file, &info, sizeof ( BITMAPINFOHEADER ), &bwritten, NULL ) == FALSE )
{
CloseHandle ( file );
return FALSE;
}

// write image data
if ( WriteFile ( file, Buffer, paddedsize, &bwritten, NULL ) == FALSE )
{
CloseHandle ( file );
return FALSE;
}

// and close file
CloseHandle ( file );

return TRUE;
}


y otra cosa como puedo guardar estas mismas imagenes pero en jpg

nota: estas imagenes son de una camara web

les agradeceria mucho si me pueden ayudar u orientar
Isack
Usuario Activo
Usuario Activo
 
Mensajes: 57
Registrado: Jue Jun 23, 2005 3:12 pm

Re: Imagenes como ??

Notapor latindeveloper el Vie Feb 03, 2006 8:47 am

Segun el codigo que estas enviando la funcion debería guardar correctamente el bitmap, seguramente la imagen ya esta invertida (BYTE *Buffer)
Imagen
Avatar de Usuario
latindeveloper
Administrador
Administrador
 
Mensajes: 1061
Registrado: Lun Jun 02, 2003 8:30 pm
Ubicación: Peru

IMAGENES COMO

Notapor Isack el Vie Feb 03, 2006 11:38 am

OK ENTONCES NO PODRIAS DECIRME COMO PUEDO HACERLE PARA QUE APARESCA EN SU FORMA NORMAL

TE AGRADESCO, GRACIAS
Isack
Usuario Activo
Usuario Activo
 
Mensajes: 57
Registrado: Jue Jun 23, 2005 3:12 pm

Re: Imagenes como ??

Notapor latindeveloper el Lun Feb 06, 2006 7:47 am

Intenta con cambiar

Código: Seleccionar todo
info.biHeight = height;


por esto:

Código: Seleccionar todo
info.biHeight = -height;
Imagen
Avatar de Usuario
latindeveloper
Administrador
Administrador
 
Mensajes: 1061
Registrado: Lun Jun 02, 2003 8:30 pm
Ubicación: Peru

imagenes como???

Notapor Isack el Sab Feb 11, 2006 12:49 pm

sabes si salio asi como tu pusistes ya lo guarda bien pero el problema es que ahora la imagen que se guarda esta del otro lado es decir si en el recurso teniendo con la camara web se ve un objeto del lado derecho al guardar aparece del lado izquierdo

te agradeceria mucho si me puedes orientar

gracias
Isack
Usuario Activo
Usuario Activo
 
Mensajes: 57
Registrado: Jue Jun 23, 2005 3:12 pm

Re: imagenes como???

Notapor latindeveloper el Dom Feb 12, 2006 12:33 pm

biWidth = -width;
Imagen
Avatar de Usuario
latindeveloper
Administrador
Administrador
 
Mensajes: 1061
Registrado: Lun Jun 02, 2003 8:30 pm
Ubicación: Peru

imagenes como

Notapor Isack el Lun Feb 13, 2006 3:45 pm

HOLA LATINDEVELOPER YA LO HABIA INTENTADO ASI COMO TU DIGISTES PERO ME MARCA UN ERROR, QUE NO SE PUEDE MOSTRAR LA IMAGEN

biWidth = -width;

Y NO SABRAS OTRA FORMA, SI SALE ANTES DE QUE ME PUEDAN ORIENTAR VOY A PONER EL CODIGO PERO GRACIAS POR TODO
Isack
Usuario Activo
Usuario Activo
 
Mensajes: 57
Registrado: Jue Jun 23, 2005 3:12 pm


Volver a Visual C++

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 0 invitados