Skip to content

Instantly share code, notes, and snippets.

View ysc3839's full-sized avatar

Richard Yu ysc3839

View GitHub Profile
@phr34k
phr34k / gist:7679738
Created November 27, 2013 17:29
Save 32-bit color rgba bitmap (hbitmap) to a png file using libpng.
#include <windows.h>
#include "extern/png/png.h"
#include <stdio.h>
BOOL SaveToFilePng(HBITMAP hBitmap, LPCSTR lpszFileName)
{
BITMAP Bitmap;
GetObject(hBitmap, sizeof(Bitmap), (LPSTR)&Bitmap);
unsigned int bitmap_bytes_per_pixel = 4;
unsigned int bitmap_scanline_size = (((Bitmap.bmWidth * bitmap_bytes_per_pixel) + (4 - 1)) & ~(4 - 1));
/*
* Minimal classList shim for IE 9
* By Devon Govett
* MIT LICENSE
*/
if (!("classList" in document.documentElement) && Object.defineProperty && typeof HTMLElement !== 'undefined') {
Object.defineProperty(HTMLElement.prototype, 'classList', {
get: function() {