diff --git a/Framework/Framework.cpp b/Framework/Framework.cpp index 696a93e..ae40a59 100644 --- a/Framework/Framework.cpp +++ b/Framework/Framework.cpp @@ -28,6 +28,12 @@ #include "Framework.h" #include #include +#include +#include +#include +#include "Tutorials/14-Refit/ImageDataHandler.h" + +//#define OFFSCREEN_RENDER namespace { @@ -44,8 +50,19 @@ namespace PostQuitMessage(0); return 0; case WM_KEYDOWN: - if (wParam == VK_ESCAPE) PostQuitMessage(0); - return 0; + switch (wParam) + { + case VK_ESCAPE: + { + PostQuitMessage(0); + } + case VK_F1: + { + ImageDataHandler imgDataHandler; + imgDataHandler.generateBitmap(); + } + } + return 0; default: return DefWindowProc(hwnd, msg, wParam, lParam); } @@ -152,12 +169,17 @@ void Framework::run(Tutorial& tutorial, const std::string& winTitle, uint32_t wi tutorial.onLoad(gWinHandle, width, height); // Show the window - ShowWindow(gWinHandle, SW_SHOWNORMAL); + #ifndef OFFSCREEN_RENDER + ShowWindow(gWinHandle, SW_SHOWNORMAL); + #endif // Start the msgLoop() msgLoop(tutorial); // Cleanup tutorial.onShutdown(); - DestroyWindow(gWinHandle); -} \ No newline at end of file + + #ifndef OFFSCREEN_RENDER + DestroyWindow(gWinHandle); + #endif +} diff --git a/Framework/Framework.props b/Framework/Framework.props index a2b7226..f8a3cd5 100644 --- a/Framework/Framework.props +++ b/Framework/Framework.props @@ -18,10 +18,10 @@ D3D12.lib;DXGI.lib;%(AdditionalDependencies) - copy /y $(SolutionDir)\Framework\Externals\dxcompiler\*.dll $(OutDir) >nul -IF not exist $(ProjectDir)\Data\ (exit /b 0) -IF not exist $(OutDir)\Data\ ( mkdir $(OutDir)\Data >nul ) -copy /y $(ProjectDir)\Data\*.* $(OutDir)\Data >nul + copy /y "$(SolutionDir)\Framework\Externals\dxcompiler\*.dll" "$(OutDir)" >nul +IF not exist "$(ProjectDir)\Data\" (exit /b 0) +IF not exist "$(OutDir)\Data\" ( mkdir "$(OutDir)\Data" >nul ) +copy /y "$(ProjectDir)\Data\*.*" "$(OutDir)\Data" >nul \ No newline at end of file diff --git a/Framework/Framework.vcxproj b/Framework/Framework.vcxproj index 85d2f50..366aecd 100644 --- a/Framework/Framework.vcxproj +++ b/Framework/Framework.vcxproj @@ -29,13 +29,13 @@ StaticLibrary true - v141 + v142 Unicode StaticLibrary false - v141 + v142 false Unicode @@ -63,7 +63,7 @@ - Level3 + TurnOffAllWarnings Disabled _PROJECT_DIR_=R"($(ProjectDir))";_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);GLM_FORCE_DEPTH_ZERO_TO_ONE $(ProjectDir);$(ProjectDir)\..\Externals\GLM;$(ProjectDir)\..\Externals\GLFW\include;$(ProjectDir)\..\Externals\FreeImage;$(ProjectDir)\..\Externals\ASSIMP\include;$(ProjectDir)\..\Externals\FFMpeg\include;$(ProjectDir)\..\Externals\OculusSDK\LibOVR\Include;$(ProjectDir)\..\Externals\OculusSDK\LibOVRKernel\Src;$(ProjectDir)\..\Externals\OpenVR\headers;$(ProjectDir)\..\Externals\RapidJson\include;$(ProjectDir)\..\Externals\VulkanSDK\Include;$(ProjectDir)\..\Externals\Python\Include;$(ProjectDir)\..\Externals\pybind11\include;$(ProjectDir)\..;$(ProjectDir)\..\Externals\;$(ProjectDir)\..\Externals\nvapi;%(AdditionalIncludeDirectories) @@ -94,7 +94,7 @@ - Level3 + TurnOffAllWarnings MaxSpeed diff --git a/Tutorials/01-CreateWindow/01-CreateWindow.vcxproj b/Tutorials/01-CreateWindow/01-CreateWindow.vcxproj index 920511b..49a5d43 100644 --- a/Tutorials/01-CreateWindow/01-CreateWindow.vcxproj +++ b/Tutorials/01-CreateWindow/01-CreateWindow.vcxproj @@ -32,13 +32,13 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/Tutorials/02-InitDXR/02-InitDXR.vcxproj b/Tutorials/02-InitDXR/02-InitDXR.vcxproj index f55e9c6..76463c7 100644 --- a/Tutorials/02-InitDXR/02-InitDXR.vcxproj +++ b/Tutorials/02-InitDXR/02-InitDXR.vcxproj @@ -32,13 +32,13 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/Tutorials/03-AccelerationStructure/03-AccelerationStructure.vcxproj b/Tutorials/03-AccelerationStructure/03-AccelerationStructure.vcxproj index 629d85c..41e0b61 100644 --- a/Tutorials/03-AccelerationStructure/03-AccelerationStructure.vcxproj +++ b/Tutorials/03-AccelerationStructure/03-AccelerationStructure.vcxproj @@ -32,13 +32,13 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/Tutorials/04-RtPipelineState/04-RtPipelineState.vcxproj b/Tutorials/04-RtPipelineState/04-RtPipelineState.vcxproj index 369f6d9..7871f3b 100644 --- a/Tutorials/04-RtPipelineState/04-RtPipelineState.vcxproj +++ b/Tutorials/04-RtPipelineState/04-RtPipelineState.vcxproj @@ -38,13 +38,13 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/Tutorials/05-ShaderTable/05-ShaderTable.vcxproj b/Tutorials/05-ShaderTable/05-ShaderTable.vcxproj index 1b9e8e8..482cfc4 100644 --- a/Tutorials/05-ShaderTable/05-ShaderTable.vcxproj +++ b/Tutorials/05-ShaderTable/05-ShaderTable.vcxproj @@ -38,13 +38,13 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/Tutorials/06-Raytrace/06-Raytrace.vcxproj b/Tutorials/06-Raytrace/06-Raytrace.vcxproj index a077619..a08e7dd 100644 --- a/Tutorials/06-Raytrace/06-Raytrace.vcxproj +++ b/Tutorials/06-Raytrace/06-Raytrace.vcxproj @@ -38,13 +38,13 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/Tutorials/07-BasicShaders/07-BasicShaders.vcxproj b/Tutorials/07-BasicShaders/07-BasicShaders.vcxproj index 5f86b8a..20d99b5 100644 --- a/Tutorials/07-BasicShaders/07-BasicShaders.vcxproj +++ b/Tutorials/07-BasicShaders/07-BasicShaders.vcxproj @@ -38,13 +38,13 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/Tutorials/08-Instancing/08-Instancing.vcxproj b/Tutorials/08-Instancing/08-Instancing.vcxproj index d8037a1..72edcf0 100644 --- a/Tutorials/08-Instancing/08-Instancing.vcxproj +++ b/Tutorials/08-Instancing/08-Instancing.vcxproj @@ -38,13 +38,13 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/Tutorials/09-ConstantBuffer/09-ConstantBuffer.vcxproj b/Tutorials/09-ConstantBuffer/09-ConstantBuffer.vcxproj index 5163bb8..8aff092 100644 --- a/Tutorials/09-ConstantBuffer/09-ConstantBuffer.vcxproj +++ b/Tutorials/09-ConstantBuffer/09-ConstantBuffer.vcxproj @@ -38,13 +38,13 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/Tutorials/10-PerInstanceConstantBuffer/10-PerInstanceConstantBuffer.vcxproj b/Tutorials/10-PerInstanceConstantBuffer/10-PerInstanceConstantBuffer.vcxproj index c93976d..f10e2f7 100644 --- a/Tutorials/10-PerInstanceConstantBuffer/10-PerInstanceConstantBuffer.vcxproj +++ b/Tutorials/10-PerInstanceConstantBuffer/10-PerInstanceConstantBuffer.vcxproj @@ -38,13 +38,13 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/Tutorials/11-SecondGeometry/11-SecondGeometry.vcxproj b/Tutorials/11-SecondGeometry/11-SecondGeometry.vcxproj index 69193b5..f92f686 100644 --- a/Tutorials/11-SecondGeometry/11-SecondGeometry.vcxproj +++ b/Tutorials/11-SecondGeometry/11-SecondGeometry.vcxproj @@ -38,13 +38,13 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/Tutorials/12-PerGeometryHitShader/12-PerGeometryHitShader.vcxproj b/Tutorials/12-PerGeometryHitShader/12-PerGeometryHitShader.vcxproj index 5e8df50..d3c7a2f 100644 --- a/Tutorials/12-PerGeometryHitShader/12-PerGeometryHitShader.vcxproj +++ b/Tutorials/12-PerGeometryHitShader/12-PerGeometryHitShader.vcxproj @@ -38,13 +38,13 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/Tutorials/13-SecondRayType/13-SecondRayType.vcxproj b/Tutorials/13-SecondRayType/13-SecondRayType.vcxproj index e028253..eb2f180 100644 --- a/Tutorials/13-SecondRayType/13-SecondRayType.vcxproj +++ b/Tutorials/13-SecondRayType/13-SecondRayType.vcxproj @@ -38,13 +38,13 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/Tutorials/14-Refit/14-Refit.cpp b/Tutorials/14-Refit/14-Refit.cpp index 5a60825..91f92e4 100644 --- a/Tutorials/14-Refit/14-Refit.cpp +++ b/Tutorials/14-Refit/14-Refit.cpp @@ -28,6 +28,8 @@ #include "14-Refit.h" #include +UINT32* pPixelData; + static dxc::DxcDllSupport gDxcDllHelper; MAKE_SMART_COM_PTR(IDxcCompiler); MAKE_SMART_COM_PTR(IDxcLibrary); @@ -1057,9 +1059,75 @@ void Tutorial14::onFrameRender() resourceBarrier(mpCmdList, mFrameObjects[rtvIndex].pSwapChainBuffer, D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_COPY_DEST); mpCmdList->CopyResource(mFrameObjects[rtvIndex].pSwapChainBuffer, mpOutputResource); + extractImageDataFromSwapchain(); + endFrame(rtvIndex); } +/***********************************************************************************/ +/***********************************************************************************/ +void Tutorial14::extractImageDataFromSwapchain() +{ + const D3D12_HEAP_PROPERTIES heapProperties = { + D3D12_HEAP_TYPE_READBACK, + D3D12_CPU_PAGE_PROPERTY_UNKNOWN, + D3D12_MEMORY_POOL_UNKNOWN, + 0, + 0 + }; + + D3D12_RESOURCE_DESC resDesc = {}; + resDesc.DepthOrArraySize = 1; + resDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; + resDesc.Format = DXGI_FORMAT_UNKNOWN; + resDesc.Height = 1; + resDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; + resDesc.MipLevels = 1; + resDesc.SampleDesc.Count = 1; + resDesc.Width = ((UINT64)mSwapChainSize.x * (UINT64)mSwapChainSize.y)*4; + + d3d_call(mpDevice->CreateCommittedResource(&heapProperties, D3D12_HEAP_FLAG_NONE, &resDesc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(&dstResource))); + + D3D12_SUBRESOURCE_FOOTPRINT subresFootprint; + subresFootprint.Depth = 1; + subresFootprint.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + subresFootprint.Width = mSwapChainSize.x; + subresFootprint.Height = mSwapChainSize.y; + subresFootprint.RowPitch = mSwapChainSize.x * 4; + + D3D12_PLACED_SUBRESOURCE_FOOTPRINT placedSubresFootprint; + placedSubresFootprint.Footprint = subresFootprint; + placedSubresFootprint.Offset = 0; + + D3D12_TEXTURE_COPY_LOCATION copyLocationDst = {}; + copyLocationDst.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; + copyLocationDst.pResource = dstResource; + copyLocationDst.PlacedFootprint = placedSubresFootprint; + + D3D12_TEXTURE_COPY_LOCATION copyLocationSrc = {}; + copyLocationSrc.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; + copyLocationSrc.pResource = mpOutputResource; + copyLocationSrc.SubresourceIndex = 0; + + mpCmdList->CopyTextureRegion(©LocationDst, 0, 0, 0, ©LocationSrc, 0); + + mFenceValue = submitCommandList(mpCmdList, mpCmdQueue, mpFence, mFenceValue); + + mpFence->SetEventOnCompletion(mFenceValue, mFenceEvent); + WaitForSingleObject(mFenceEvent, INFINITE); + + UINT32* pPixelDataBegin; + + dstResource->Map(0, nullptr, reinterpret_cast(&pPixelDataBegin)); + + pPixelDataBegin[0]; + + pPixelData = pPixelDataBegin; +} +/***********************************************************************************/ +/***********************************************************************************/ + + void Tutorial14::onShutdown() { // Wait for the command queue to finish execution diff --git a/Tutorials/14-Refit/14-Refit.h b/Tutorials/14-Refit/14-Refit.h index e486442..5220fbe 100644 --- a/Tutorials/14-Refit/14-Refit.h +++ b/Tutorials/14-Refit/14-Refit.h @@ -27,6 +27,7 @@ ***************************************************************************/ #pragma once #include "Framework.h" +#include "ImageDataHandler.h" class Tutorial14 : public Tutorial { @@ -38,9 +39,12 @@ class Tutorial14 : public Tutorial ID3D12ResourcePtr pInstanceDesc; // Used only for top-level AS }; + void onLoad(HWND winHandle, uint32_t winWidth, uint32_t winHeight) override; - void onFrameRender() override; + void onFrameRender() override; + void extractImageDataFromSwapchain(); void onShutdown() override; + private: ////////////////////////////////////////////////////////////////////////// // Tutorial 02 code @@ -57,6 +61,7 @@ class Tutorial14 : public Tutorial ID3D12FencePtr mpFence; HANDLE mFenceEvent; uint64_t mFenceValue = 0; + ID3D12ResourcePtr dstResource; struct { diff --git a/Tutorials/14-Refit/14-Refit.vcxproj b/Tutorials/14-Refit/14-Refit.vcxproj index b693db6..4eae96c 100644 --- a/Tutorials/14-Refit/14-Refit.vcxproj +++ b/Tutorials/14-Refit/14-Refit.vcxproj @@ -12,9 +12,11 @@ + + @@ -38,13 +40,13 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode @@ -72,7 +74,7 @@ - Level3 + TurnOffAllWarnings Disabled WIN32;_DEBUG;%(PreprocessorDefinitions) @@ -86,7 +88,7 @@ - Level3 + TurnOffAllWarnings MaxSpeed diff --git a/Tutorials/14-Refit/14-Refit.vcxproj.filters b/Tutorials/14-Refit/14-Refit.vcxproj.filters index d23829e..d493f7d 100644 --- a/Tutorials/14-Refit/14-Refit.vcxproj.filters +++ b/Tutorials/14-Refit/14-Refit.vcxproj.filters @@ -7,9 +7,11 @@ + + diff --git a/Tutorials/14-Refit/ImageDataHandler.cpp b/Tutorials/14-Refit/ImageDataHandler.cpp new file mode 100644 index 0000000..e33b926 --- /dev/null +++ b/Tutorials/14-Refit/ImageDataHandler.cpp @@ -0,0 +1,268 @@ +#pragma once +#include +#include +#include "ImageDataHandler.h" +#include + +// Save the bitmap to a bmp file +void ImageDataHandler::saveScreenshot(BYTE* pBitmapBits, + LONG lWidth, + LONG lHeight, + WORD wBitsPerPixel, + const unsigned long& padding_size, + LPCTSTR lpszFileName) +{ + // Some basic bitmap parameters + unsigned long headers_size = sizeof(BITMAPFILEHEADER) + + sizeof(BITMAPINFOHEADER); + + unsigned long pixel_data_size = lHeight * ((lWidth * (wBitsPerPixel / 8)) + padding_size); + + BITMAPINFOHEADER bmpInfoHeader = { 0 }; + + // Set the size + bmpInfoHeader.biSize = sizeof(BITMAPINFOHEADER); + + // Bit count + bmpInfoHeader.biBitCount = wBitsPerPixel; + + // Use all colors + bmpInfoHeader.biClrImportant = 0; + + // Use as many colors according to bits per pixel + bmpInfoHeader.biClrUsed = 0; + + // Store as un Compressed + bmpInfoHeader.biCompression = BI_RGB; + + // Set the height in pixels + bmpInfoHeader.biHeight = lHeight; + + // Width of the Image in pixels + bmpInfoHeader.biWidth = lWidth; + + // Default number of planes + bmpInfoHeader.biPlanes = 1; + + // Calculate the image size in bytes + bmpInfoHeader.biSizeImage = pixel_data_size; + + BITMAPFILEHEADER bfh = { 0 }; + + // This value should be values of BM letters i.e 0x4D42 + // 0x4D = M 0�42 = B storing in reverse order to match with endian + bfh.bfType = 0x4D42; + //bfh.bfType = 'B'+('M' << 8); + + // <<8 used to shift �M� to end */ + + // Offset to the RGBQUAD + bfh.bfOffBits = headers_size; + + // Total size of image including size of headers + bfh.bfSize = headers_size + pixel_data_size; + + // Create the file in disk to write + HANDLE hFile = CreateFile(lpszFileName, + GENERIC_WRITE, + 0, + NULL, + CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + NULL); + + // Return if error opening file + if (!hFile) return; + + DWORD dwWritten = 0; + + // Write the File header + WriteFile(hFile, + &bfh, + sizeof(bfh), + &dwWritten, + NULL); + + // Write the bitmap info header + WriteFile(hFile, + &bmpInfoHeader, + sizeof(bmpInfoHeader), + &dwWritten, + NULL); + + // Write the RGB Data + WriteFile(hFile, + pBitmapBits, + bmpInfoHeader.biSizeImage, + &dwWritten, + NULL); + + // Close the file handle + CloseHandle(hFile); +} + +BYTE* ImageDataHandler::LoadBMP(int* width, int* height, unsigned long* size, LPCTSTR bmpfile) +{ + BITMAPFILEHEADER bmpheader; + BITMAPINFOHEADER bmpinfo; + // value to be used in ReadFile funcs + DWORD bytesread; + // open file to read from + HANDLE file = CreateFile(bmpfile, + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_FLAG_SEQUENTIAL_SCAN, + NULL); + if (NULL == file) + return NULL; + + if (ReadFile(file, &bmpheader, sizeof(BITMAPFILEHEADER), &bytesread, NULL) == false) + { + CloseHandle(file); + return NULL; + } + + // Read bitmap info + if (ReadFile(file, &bmpinfo, sizeof(BITMAPINFOHEADER), &bytesread, NULL) == false) + { + CloseHandle(file); + return NULL; + } + + // check if file is actually a bmp + if (bmpheader.bfType != 'MB') + { + CloseHandle(file); + return NULL; + } + + // get image measurements + *width = bmpinfo.biWidth; + *height = abs(bmpinfo.biHeight); + + // Check if bmp iuncompressed + if (bmpinfo.biCompression != BI_RGB) + { + CloseHandle(file); + return NULL; + } + + // Check if we have 24 bit bmp + if (bmpinfo.biBitCount != 24) + { + CloseHandle(file); + return NULL; + } + + // create buffer to hold the data + *size = bmpheader.bfSize - bmpheader.bfOffBits; + BYTE* Buffer = new BYTE[*size]; + // move file pointer to start of bitmap data + SetFilePointer(file, bmpheader.bfOffBits, NULL, FILE_BEGIN); + // read bmp data + if (ReadFile(file, Buffer, *size, &bytesread, NULL) == false) + { + delete[] Buffer; + CloseHandle(file); + return NULL; + } + + // everything successful here: close file and return buffer + + CloseHandle(file); + + return Buffer; +} + +std::unique_ptr ImageDataHandler::CreateNewBuffer(unsigned long& padding, + BYTE* pmatrix, + const int& width, + const int& height) +{ + padding = (4 - ((width * 3) % 4)) % 4; + int scanlinebytes = width * 3; + int total_scanlinebytes = scanlinebytes + padding; + long newsize = height * total_scanlinebytes; + std::unique_ptr newbuf(new BYTE[newsize]); + + // Fill new array with original buffer, pad remaining with zeros + std::fill(&newbuf[0], &newbuf[newsize], 0); + long bufpos = 0; + long newpos = 0; + for (int y = 0; y < height; y++) + { + for (int x = 0; x < 3 * width; x += 3) + { + // Determine positions in original and padded buffers + bufpos = y * 3 * width + (3 * width - x); + newpos = (height - y - 1) * total_scanlinebytes + x; + + // Swap R&B, G remains, swap B&R + newbuf[newpos] = pmatrix[bufpos + 2]; + newbuf[newpos + 1] = pmatrix[bufpos + 1]; + newbuf[newpos + 2] = pmatrix[bufpos]; + } + } + + return newbuf; +} + +void ImageDataHandler::generateBitmap() +{ + + const int dataSize = 1920 * 1061 * 3; + BYTE* buf = new BYTE[dataSize]; + + for (int y = 0; y < 1061; ++y) + { + for (int x = 0; x < 1920; ++x) + { + unsigned char abgr[4]; + UINT32 temp = pPixelData[y * 1920 + x]; + + abgr[0] = (temp >> 24) & 0xFF; + abgr[1] = (temp >> 16) & 0xFF; + abgr[2] = (temp >> 8) & 0xFF; + abgr[3] = temp & 0xFF; + + buf[(y * 1920 + x) * 3] = abgr[1]; + buf[(y * 1920 + x) * 3+1] = abgr[2]; + buf[(y * 1920 + x) * 3+2] = abgr[3]; + } + } + + buf[0]; + buf[1]; + buf[2]; + int c = 0; + + for (int y = 0; y < 1061; y++) + { + BYTE temp[1920]; + for (int i = 0; i < 1920; i++) + { + temp[i] = buf[y * 1920 + i]; + } + + for (int i = 0; i < 1080; i++) + { + buf[y * 1920 + i] = buf[(1060 - y) * 1920 + i]; + } + + for (int i = 0; i < 1920; i++) + { + buf[(1060 - y) * 1920 + i] = temp[i]; + } + } + + saveScreenshot((BYTE*)buf, + 1920, + 1061, + 24, + 0, + L"file2.bmp"); + + delete[] buf; +} \ No newline at end of file diff --git a/Tutorials/14-Refit/ImageDataHandler.h b/Tutorials/14-Refit/ImageDataHandler.h new file mode 100644 index 0000000..cb7ebac --- /dev/null +++ b/Tutorials/14-Refit/ImageDataHandler.h @@ -0,0 +1,30 @@ +#pragma once +#include +#include +#include +#include +#include "Windows.h" + +extern UINT32* pPixelData; + +class ImageDataHandler +{ +public: + void saveScreenshot(BYTE* pBitmapBits, + LONG lWidth, + LONG lHeight, + WORD wBitsPerPixel, + const unsigned long& padding_size, + LPCTSTR lpszFileName); + + void generateBitmap(); + + std::unique_ptr CreateNewBuffer(unsigned long& padding, + BYTE* pmatrix, + const int& width, + const int& height); + + BYTE* LoadBMP(int* width, int* height, unsigned long* size, LPCTSTR bmpfile); + + void setInt(unsigned char* mem, int data); +}; \ No newline at end of file diff --git a/Tutorials/14-Refit/file.bmp b/Tutorials/14-Refit/file.bmp new file mode 100644 index 0000000..e69de29 diff --git a/Tutorials/14-Refit/file2.bmp b/Tutorials/14-Refit/file2.bmp new file mode 100644 index 0000000..ba42f79 Binary files /dev/null and b/Tutorials/14-Refit/file2.bmp differ