rainmeter-studio/Common/Gfx/WICBitmapLockDIB.h
Birunthan Mohanathas 5f03d7b235 Gfx: Fix rendering issues in some cases
It seems that Direct2D does not expect the underlying pixel data of the render target to change outside of the target draw commands while the render target exists. As a result, Direct2D may in some cases overwrite changes to the pixel data. This change changes the render target to be (re)created for each batch of Direct2D drawing operations as a temporary solution. As a side effect, a DIB section is now used as the render target bitmap.
2013-03-26 21:29:05 +02:00

59 lines
1.8 KiB
C++

/*
Copyright (C) 2013 Birunthan Mohanathas
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef RM_GFX_WICBITMAPLOCKDIB_H_
#define RM_GFX_WICBITMAPLOCKDIB_H_
#include <Windows.h>
#include <GdiPlus.h>
#include <wincodec.h>
#include "WICBitmapDIB.h"
namespace Gfx {
// Implements the IWICBitmapLock interface for use with WICBitmapDIB. It is assumed that this
// class is used only with 32bpp PARGB bitmaps and using a sigle thread.
class WICBitmapLockDIB : public IWICBitmapLock
{
public:
WICBitmapLockDIB(WICBitmapDIB* bitmap, const WICRect* lockRect);
virtual ~WICBitmapLockDIB();
void Resize(UINT w, UINT h);
// IUnknown
IFACEMETHOD(QueryInterface)(REFIID riid, void** ppvObject);
IFACEMETHOD_(ULONG, AddRef)();
IFACEMETHOD_(ULONG, Release)();
// IWICBitmapLock
IFACEMETHOD(GetSize)(UINT* puiWidth, UINT* puiHeight);
IFACEMETHOD(GetStride)(UINT* pcbStride);
IFACEMETHOD(GetDataPointer)(UINT* pcbBufferSize, BYTE** ppbData);
IFACEMETHOD(GetPixelFormat)(WICPixelFormatGUID* pPixelFormat);
private:
WICBitmapDIB* m_Bitmap;
const WICRect* m_Rect;
UINT m_RefCount;
};
} // namespace Gfx
#endif