#include "config.h"
#include "Image.h"
#include "BitmapImage.h"
#include "BitmapInfo.h"
#include "GraphicsContext.h"
#include "ImageObserver.h"
#include "NotImplemented.h"
#include <d2d1.h>
#include <windows.h>
#include <wtf/RetainPtr.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
RefPtr<BitmapImage> BitmapImage::create(HBITMAP hBitmap)
{
DIBSECTION dibSection;
if (!GetObject(hBitmap, sizeof(DIBSECTION), &dibSection))
return nullptr;
ASSERT(dibSection.dsBm.bmBitsPixel == 32);
if (dibSection.dsBm.bmBitsPixel != 32)
return nullptr;
ASSERT(dibSection.dsBm.bmBits);
if (!dibSection.dsBm.bmBits)
return nullptr;
notImplemented();
return nullptr;
}
bool BitmapImage::getHBITMAPOfSize(HBITMAP bmp, const IntSize* size)
{
ASSERT(bmp);
BITMAP bmpInfo;
GetObject(bmp, sizeof(BITMAP), &bmpInfo);
ASSERT(bmpInfo.bmBitsPixel == 32);
int bufferSize = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;
notImplemented();
return true;
}
void BitmapImage::drawFrameMatchingSourceSize(GraphicsContext& ctxt, const FloatRect& dstRect, const IntSize& srcSize, CompositeOperator compositeOp)
{
size_t frames = frameCount();
for (size_t i = 0; i < frames; ++i) {
auto image = frameImageAtIndex(i).get();
auto imageSize = nativeImageSize(image);
if (image && clampTo<int>(imageSize.height()) == static_cast<int>(srcSize.height()) && clampTo<int>(imageSize.width()) == static_cast<int>(srcSize.width())) {
size_t currentFrame = m_currentFrame;
m_currentFrame = i;
draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, srcSize.width(), srcSize.height()), { compositeOp });
m_currentFrame = currentFrame;
return;
}
}
FloatSize imageSize = BitmapImage::size();
draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), { compositeOp });
}
}