Este es el code que e ido generando y el cual me gustaria editar para reducir el tamaño del archivo final.
Código:
// ConsoleApplication7.cpp: define el punto de entrada de la aplicación de consola.
//
#include "stdafx.h"
#include <stdio.h>
#include <Windows.h>
#include <d3d9.h>
#include <d3dx9.h>
#include <D3dx9tex.h>
#include <iostream>
#include <fstream>
using namespace std;
#pragma comment( lib, "d3d9.lib" )
#pragma comment( lib, "d3dx9.lib" )
void main()
{
CoInitialize(NULL);
LPDIRECT3D9 d3d9;
LPDIRECT3DDEVICE9 d3ddev;
d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
int ww = GetSystemMetrics(SM_CXSCREEN);
int wh = GetSystemMetrics(SM_CYSCREEN);
HWND hwnd = GetDesktopWindow();
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.BackBufferCount = 3;
d3dpp.BackBufferWidth = ww;
d3dpp.BackBufferHeight = wh;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.MultiSampleQuality = 0;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.hDeviceWindow = hwnd;
d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &d3ddev);
IDirect3DSurface9* render;
IDirect3DSurface9* dest;
int i = 0;
while (i++ < 100){
d3ddev->CreateOffscreenPlainSurface(ww, wh, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &dest, NULL);
d3ddev->GetFrontBufferData(0, dest);
LPD3DXBUFFER buffer;
D3DXSaveSurfaceToFileInMemory(&buffer, D3DXIFF_JPG, dest, NULL, NULL);
DWORD imSize = buffer->GetBufferSize();
void* imgBuffer = buffer->GetBufferPointer();
fstream out;
///////////////////////
char file[100];
snprintf(file, 100, "toni%d.jpg", i);
////////////////////
out.open(file, std::ios_base::binary | std::ios_base::out);
out.write((char*)imgBuffer, imSize);
out.clear();
out.close();
dest->Release();
}
d3ddev->Release();
d3d9->Release();
CoUninitialize();
}