mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-03-31 08:52:37 +02:00
byuu says: Changelog: - sfc/ppu-fast: added hires mode 7 option (doubles the sampling rate of mode 7 pixels to reduce aliasing) - sfc/ppu-fast: fixed mode 7 horizontal screen flip [hex_usr] - bsnes: added capture screenshot function and path selection - for now, it saves as BMP. I need a deflate implementation that won't add an external dependency for PNG - the output resolution is from the emulator: (256 or 512)x(240 or 480 minus overscan cropping if enabled) - it captures the NEXT output frame, not the current one ... but it may be wise to change this behavior - it'd be a problem if the core were to exit and an image was captured halfway through frame rendering - bsnes: recovery state renamed to undo state - bsnes: added manifest viewer tool - bsnes: mention if game has been verified or not on the status bar message at load time - bsnes, nall: fixed a few missing function return values [SuperMikeMan] - bsnes: guard more strongly against failure to load games to avoid crashes - hiro, ruby: various fixes for macOS [Sintendo] - hiro/Windows: paint on `WM_ERASEBKGND` to prevent status bar flickering at startup - icarus: SPC7110 heuristics fixes [hex_usr] Errata: - sfc/ppu-fast: remove debug hires mode7 force disable comment from PPU::power() [The `WM_ERASEBKGND` fix was already present in the 106r44 public beta -Ed.]
48 lines
1.6 KiB
C++
48 lines
1.6 KiB
C++
#pragma once
|
|
|
|
namespace nall { namespace Encode {
|
|
|
|
struct BMP {
|
|
static auto create(const string& filename, const uint32_t* data, uint pitch, uint width, uint height, bool alpha) -> bool {
|
|
file fp{filename, file::mode::write};
|
|
if(!fp) return false;
|
|
|
|
uint bitsPerPixel = alpha ? 32 : 24;
|
|
uint bytesPerPixel = bitsPerPixel / 8;
|
|
uint alignedWidth = width * bytesPerPixel;
|
|
uint paddingLength = 0;
|
|
uint imageSize = alignedWidth * height;
|
|
uint fileSize = 0x36 + imageSize;
|
|
while(alignedWidth % 4) alignedWidth++, paddingLength++;
|
|
|
|
fp.writel(0x4d42, 2); //signature
|
|
fp.writel(fileSize, 4); //file size
|
|
fp.writel(0, 2); //reserved
|
|
fp.writel(0, 2); //reserved
|
|
fp.writel(0x36, 4); //offset
|
|
|
|
fp.writel(40, 4); //DIB size
|
|
fp.writel(width, 4); //width
|
|
fp.writel(-height, 4); //height
|
|
fp.writel(1, 2); //color planes
|
|
fp.writel(bitsPerPixel, 2); //bits per pixel
|
|
fp.writel(0, 4); //compression method (BI_RGB)
|
|
fp.writel(imageSize, 4); //image data size
|
|
fp.writel(3780, 4); //horizontal resolution
|
|
fp.writel(3780, 4); //vertical resolution
|
|
fp.writel(0, 4); //palette size
|
|
fp.writel(0, 4); //important color count
|
|
|
|
pitch >>= 2;
|
|
for(auto y : range(height)) {
|
|
const uint32_t* p = data + y * pitch;
|
|
for(auto x : range(width)) fp.writel(*p++, bytesPerPixel);
|
|
if(paddingLength) fp.writel(0, paddingLength);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
};
|
|
|
|
}}
|