<commit_before>
#include "config.h"
#include <windows.h>

#include "platform/image-decoders/GDIPlus/GDIPlusReader.h"

#undef min
#undef max
using std::max;
using std::min;
#include <gdiplus.h>

namespace blink {

GDIPlusReader::GDIPlusReader(ImageDecoder* parent, Gdiplus::Bitmap* gdipBitmap)
    : m_parent(parent)
    , m_buffer(0)
    , m_gdipBitmap(gdipBitmap)
{

}

GDIPlusReader::~GDIPlusReader()
{
    delete m_gdipBitmap;
    m_gdipBitmap = nullptr;
}

static void fillbitmap(Gdiplus::Bitmap* gdipBitmap, ImageFrame* buffer)
{
    UINT w = gdipBitmap->GetWidth();
    UINT h = gdipBitmap->GetHeight();

    Gdiplus::Rect rect(0, 0, w, h);
    Gdiplus::BitmapData lockedBitmapData;
    gdipBitmap->LockBits(&rect, Gdiplus::ImageLockModeRead, PixelFormat32bppARGB, &lockedBitmapData);

    unsigned int *pData = reinterpret_cast<unsigned int *>(lockedBitmapData.Scan0);
    int stride = lockedBitmapData.Stride;

    UINT hasAlpha = 0xff000000;
    for (UINT x = 0; x < w; ++x) {
        for (UINT y = 0; y < h; ++y) {
            UINT color = pData[y * stride / 4 + x]; // color= 0xAARRGGBB
            hasAlpha &= color;
            UINT red = GetRValue(color);
            UINT green = GetGValue(color);
            UINT blue = GetBValue(color);
            UINT alpha = (LOBYTE((color) >> 24));
            buffer->setRGBA(x, y, red, green, blue, alpha);
        }
    }

    buffer->setHasAlpha(!hasAlpha);
    
    gdipBitmap->UnlockBits(&lockedBitmapData);
}
<commit_msg>* 修复vc6crt模式编译错误<commit_after>
#include "config.h"
#include <windows.h>

#include "platform/image-decoders/GDIPlus/GDIPlusReader.h"

#undef min
#undef max
using std::max;
using std::min;
#include <gdiplus.h>

namespace blink {

GDIPlusReader::GDIPlusReader(ImageDecoder* parent, Gdiplus::Bitmap* gdipBitmap)
    : m_parent(parent)
    , m_buffer(0)
    , m_gdipBitmap(gdipBitmap)
{

}

GDIPlusReader::~GDIPlusReader()
{
    delete m_gdipBitmap;
    m_gdipBitmap = nullptr;
}

static void fillbitmap(Gdiplus::Bitmap* gdipBitmap, ImageFrame* buffer)
{
    UINT w = gdipBitmap->GetWidth();
    UINT h = gdipBitmap->GetHeight();

    Gdiplus::Rect rect(0, 0, w, h);
    Gdiplus::BitmapData lockedBitmapData;
    gdipBitmap->LockBits(
#if USING_VC6RT != 1
        &
#endif
        rect, Gdiplus::ImageLockModeRead, PixelFormat32bppARGB, &lockedBitmapData);

    unsigned int *pData = reinterpret_cast<unsigned int *>(lockedBitmapData.Scan0);
    int stride = lockedBitmapData.Stride;

    UINT hasAlpha = 0xff000000;
    for (UINT x = 0; x < w; ++x) {
        for (UINT y = 0; y < h; ++y) {
            UINT color = pData[y * stride / 4 + x]; // color= 0xAARRGGBB
            hasAlpha &= color;
            UINT red = GetRValue(color);
            UINT green = GetGValue(color);
            UINT blue = GetBValue(color);
            UINT alpha = (LOBYTE((color) >> 24));
            buffer->setRGBA(x, y, red, green, blue, alpha);
        }
    }

    buffer->setHasAlpha(!hasAlpha);
    
    gdipBitmap->UnlockBits(&lockedBitmapData);
}

{'fraction_non_alphanumeric': 0.13225058004640372, 'fraction_numerical': 0.01358965860125953, 'mean_word_length': 3.1742738589211617, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5631185', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1064, 'n_words': 228}