mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-20 06:11:29 +02:00
Update to v094r38 release.
byuu says: I'll post more detailed changes later, but basically: - fixed Baldur's Gate bug - guess if no flash ROM ID present (fixes Magical Vacation, many many others) - nall cleanups - sfc/cartridge major cleanups - bsxcartridge/"bsx" renamed to mcc/"mcc" after the logic chip it uses (consistency with SGB/ICD2) - ... and more!
This commit is contained in:
49
nall/encode/bmp.hpp
Normal file
49
nall/encode/bmp.hpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef NALL_ENCODE_BMP_HPP
|
||||
#define NALL_ENCODE_BMP_HPP
|
||||
|
||||
namespace nall { namespace Encode {
|
||||
|
||||
struct BMP {
|
||||
static auto create(const string& filename, const uint32_t* data, unsigned width, unsigned height, bool alpha) -> bool {
|
||||
file fp{filename, file::mode::write};
|
||||
if(!fp) return false;
|
||||
|
||||
unsigned bitsPerPixel = alpha ? 32 : 24;
|
||||
unsigned bytesPerPixel = bitsPerPixel / 8;
|
||||
unsigned alignedWidth = width * bytesPerPixel;
|
||||
unsigned paddingLength = 0;
|
||||
unsigned imageSize = alignedWidth * height;
|
||||
unsigned 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
|
||||
|
||||
for(auto y : range(height)) {
|
||||
const uint32_t* p = data + y * width;
|
||||
for(auto x : range(width)) fp.writel(*p++, bytesPerPixel);
|
||||
if(paddingLength) fp.writel(0, paddingLength);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user