22 #include "../../gpu/pipeline.h"
23 #include "../../context.h"
24 #include "../../exception.h"
40 static bool gdiStartedUp =
false;
43 Gdiplus::GdiplusStartupInput gdiplusStartupInput;
44 ULONG_PTR gdiplusToken;
45 Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
54 Gdiplus::ImageCodecInfo* pImageCodecInfo = NULL;
56 Gdiplus::GetImageEncodersSize(&num, &
size);
60 pImageCodecInfo = (Gdiplus::ImageCodecInfo*)(malloc(
size));
61 if (pImageCodecInfo == NULL)
64 Gdiplus::GetImageEncoders(num,
size, pImageCodecInfo);
66 for (UINT j = 0; j < num; ++j)
68 if (wcscmp(pImageCodecInfo[j].MimeType,
format) == 0)
70 *pClsid = pImageCodecInfo[j].Clsid;
71 free(pImageCodecInfo);
76 free(pImageCodecInfo);
95 pf = PixelFormat24bppRGB;
99 pf = PixelFormat32bppARGB;
113 switch (
bitmap->GetPixelFormat()) {
114 case PixelFormat8bppIndexed:
return SingleByte;
116 case PixelFormat32bppARGB:
return QuadByte;
138 bitmap->LockBits(&
size, Gdiplus::ImageLockModeRead | Gdiplus::ImageLockModeWrite,
bitmap->GetPixelFormat(), &
data);
158 else if (wcsstr(
filename, L
".png")) {
A very basic class for any image.
Context & ctx
context managing this bitmap
const unsigned char getBitsPerPixel() const
Returns number of bits per pixel stored in each bitmap.
Basic class: task and memory management, any kind of static data.
void unlockPixelData()
Unlocks access to the CPU memory buffer containing pixel data.
GDIBitmap(Context &ctx, const wchar_t *filename)
const int getHeight() const
Height of the texture in pixels.
void lockPixelData()
Locks access to the CPU memory buffer containing pixel data.
const msize getMemorySize() const
Bitmap size in bytes.
void save(const wchar_t *filename)
const int getWidth() const
Width of the texture in pixels.
const pixbyte * getData(int x, int y) const
Returns a pointer to given pixel.
const PixelFormat getPixelFormat() const
Pixel format of the bitmap.
A simple wrapper of IL image.
const pixbyte * getData(int x, int y) const
Impl(Context &ctx, const wchar_t *filename)
void save(const WCHAR *filename)
Impl(Context &ctx, int width, int height, PixelFormat format)
const PixelFormat getPixelFormat() const
const int getHeight() const
static int GetEncoderClsid(const WCHAR *format, CLSID *pClsid)
const int getWidth() const
uint32_t msize
memory size
@ SingleByte
single channel of 8 bits per pixel (like grayscale), unsigned integer values
@ QuadByte
4 channels of 8 bits per pixel (like RGBA), unsigned integer values
@ TripleByte
3 channels of 8 bits per pixel (like RGB), unsigned integer values
#define ceili(x, y)
integer division x/y with ceiling
JNIEnv jobject jint format
jobject jlong jint jint y
JNIEnv jlong jstring filename