Thread View: microsoft.public.vb.winapi.graphics
4 messages
4 total messages
Started by S�bastien Dionne
Fri, 11 Sep 1998 00:00
stream to bmp in API
Author: S�bastien Dionne
Date: Fri, 11 Sep 1998 00:00
Date: Fri, 11 Sep 1998 00:00
114 lines
4802 bytes
4802 bytes
I have this code... I wanna save each frame in a bmp file.. how I can do
that ?
#include <windows.h>
#include <windows.h>
#include <windowsx.h>
#include <mmsystem.h>
#include <commdlg.h>
#include <vfw.h>
#include <memory.h>
DWORD dwImageSize = (DWORD)320 * (DWORD)240 * 3; // 640 * 480 *
24 bpp
void AviPlayer(HWND hWnd, char* szFilename)
{
PAVIFILE pavif;
PAVISTREAM pavis;
AVIFILEINFO afi;
LPBITMAPINFOHEADER biFmt;
LPSTR szBuffering;
HDC hdcDisplay;
HDRAWDIB hddOp;
LONG lIndex, lLength;
// Initialisation du sous-syst�me AVI
AVIFileInit();
// Ouverture du fichier utilisateur en mode lecture seule et en
mode partage
AVIFileOpen(&pavif, szFilename, OF_READ, NULL);
// R�cup�ration des informations sur le copyright, stream name,
etc.
AVIFileInfo(pavif, &afi, sizeof(AVIFILEINFO));
// Trouver le premier flux video (obligatoire)
AVIFileGetStream(pavif, &pavis, streamtypeVIDEO, 0);
// Taille en octets d'un bloc video
AVIStreamFormatSize(pavis, 0, &lLength);
// Allocation de de l'espace n�cessaire en fonction du format
biFmt =
(LPBITMAPINFOHEADER)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,
lLength);
szBuffering = (LPSTR)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, dwImageSize);
// Obtention du DC pour l'affichage
hdcDisplay = GetWindowDC(hWnd);
// Lecture du format d'un bloc sur la sortie video
AVIStreamReadFormat(pavis, 0, biFmt, &lLength);
// Combien de frames contient le flux video ?
lLength = AVIStreamLength(pavis);
// Retailler le fen�tre a la taille exacte du film
SetWindowPos(hWnd, HWND_TOP, 0, 0, (UINT)biFmt->biWidth,
(UINT)biFmt->biHeight, SWP_NOMOVE);
// Cr�ation de l'objet DrawDib
hddOp = DrawDibOpen();
// Initialisation des propri�t�s de l'objet DrawDib
DrawDibBegin(hddOp, hdcDisplay, 0, 0, biFmt,
(UINT)biFmt->biWidth,(UINT)biFmt->biHeight,
DDF_SAME_HDC);
// Finalement afficher la fen�tre
ShowWindow(hWnd, SW_RESTORE);
// Maintenant faire une boucle sur la lecture du flux videopour
lire l'ensemble des
// frame le plus rapidement possible. Les frames video sont
d�compress�es par la
// fonction AVIStreamRead() en DIBs (dans le buffer
szBuffering) ainsi nous n'avons
// pas � nous pr\eoccuper de la d�compression.
for (lIndex = 0; lIndex < lLength; ++lIndex) {
LONG uLong = dwImageSize;
AVIStreamRead(pavis, lIndex, 1, szBuffering, dwImageSize,
&uLong, NULL);
DrawDibDraw(hddOp, hdcDisplay, 0, 0, (UINT)biFmt->biWidth,
(UINT)biFmt->biHeight, biFmt, szBuffering, 0,
0,
(UINT)biFmt->biWidth, (UINT)biFmt->biHeight,
0);
} // Affichage de chaque Frame
// R�afficher la fen�tre application
ShowWindow(hWnd, SW_HIDE);
ShowWindow(hWnd, SW_SHOW);
// Lib�ration du DC
ReleaseDC(hWnd, hdcDisplay);
// Lib�ration des ressources du flux video
AVIStreamRelease(pavis);
AVIFileRelease(pavif);
// Lib�ration de la m�moire allou�e
HeapFree(GetProcessHeap(), 0, (LPVOID)biFmt);
HeapFree(GetProcessHeap(), 0, (LPVOID)szBuffering);
// Fermeture de l'objet DrawDib et du sous-syst�me AVI
DrawDibClose(hddOp);
AVIFileExit();
}
Re: stream to bmp in API
Author: S�bastien Dionne
Date: Mon, 14 Sep 1998 00:00
Date: Mon, 14 Sep 1998 00:00
5 lines
1158 bytes
1158 bytes
???? Ross wrote: > ��<
Re: stream to bmp in API
Author: Bertie Wooster
Date: Tue, 15 Sep 1998 00:00
Date: Tue, 15 Sep 1998 00:00
11 lines
1232 bytes
1232 bytes
Yep. S�bastien Dionne wrote in message <35FD1B9B.D313FAC1@gel.usherb.ca>... >???? > >Ross wrote: > >> ��< > > >
Re: stream to bmp in API
Author: Vanderghast
Date: Wed, 16 Sep 1998 00:00
Date: Wed, 16 Sep 1998 00:00
18 lines
1339 bytes
1339 bytes
Salut S�bastien, C'est du C tu sais? Il y a surement des ng en vc++ qui pourraient mieux t'aider. Vanderghast, Access MVP. S�bastien Dionne wrote in message <35FD1B9B.D313FAC1@gel.usherb.ca>... >???? > >Ross wrote: > >> ��< > > >
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads