Ver Mensaje Individual
  #4 (permalink)  
Antiguo 26/01/2007, 08:32
Avatar de Eternal Idol
Eternal Idol
 
Fecha de Ingreso: mayo-2004
Ubicación: Lucentum
Mensajes: 6.192
Antigüedad: 20 años, 9 meses
Puntos: 74
Re: OleLoadPicture Cuelgue

¿Estas seguro de que el problema es en OleLoadPicture? Yo acabo de probar primero abriendo un JPG (CreateFile, ReadFile, CreateStreamOnHGlobal, OleLoadPicture y iPicture->Render) y despues "corrompiendo" esos mismos datos con un codigo de prueba muy pero muy simple y OleLoadPicture es lo suficientemente inteligente como para no devolver un hr de exito y dejar m_IPicture en 0.


Tal vez puedas darnos mas codigo o un binario ...

Código:
        HANDLE hFile = CreateFile("C:\\WINDOWS\\Web\\Wallpaper\\Autumn.jpg", GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
	DWORD nSize = GetFileSize(hFile, 0);
	IStream *pStream = 0;
	LPBYTE buff = (LPBYTE)malloc(nSize);
	DWORD read = 0;
	ReadFile(hFile, buff, nSize, &read, 0);
	CloseHandle(hFile);
	 
	HGLOBAL globalAlloc = GlobalAlloc(GMEM_MOVEABLE, nSize);
	LPBYTE imageBuffer = (LPBYTE)GlobalLock(globalAlloc);
	CopyMemory(imageBuffer, buff, nSize);
	GlobalUnlock(globalAlloc);
	CreateStreamOnHGlobal(globalAlloc, true, &pStream);
	
	for (int x = nSize / 2; x < nSize; x++)
	{
		imageBuffer[x] = imageBuffer[x] * 2;
	}

	IPicture *iPicture = NULL;
	printf("0x%X\r\n", OleLoadPicture(pStream, 0, FALSE, IID_IPicture, (void**) &iPicture));
	printf("0x%X\r\n", iPicture);

	if (iPicture)
	{
		HDC hdc = GetDC(0);
		OLE_XSIZE_HIMETRIC width, height;
		iPicture->get_Width(&width);
		iPicture->get_Height(&height);
		LONG cx = GetDeviceCaps(hdc, LOGPIXELSX) * width / 2540;
		LONG cy = GetDeviceCaps(hdc, LOGPIXELSX) * height / 2540;
		iPicture->Render(hdc, 0, 0, cx, cy, 0, height, width, -height, NULL);
		ReleaseDC(0, hdc);
	}
	pStream->Release();
	GlobalFree(globalAlloc);
__________________
¡Peron cumple, Evita dignifica! VIVA PERON CARAJO