146 HRESULT hr = S_FALSE;
152 file->reader.offset = 0;
153 file->_pStream = _pStream;
155 file->reader.seek(&file->reader, 0, SEEK_SET);
164 for (
int i = 0; i < thumb.
width * thumb.
height; i++) {
165 std::swap(thumb.
data[4 * i], thumb.
data[4 * i + 2]);
172 *pdwAlpha = WTSAT_ARGB;
177 LONG NewWidth = LONG(thumb.
width * scale);
178 LONG NewHeight = LONG(thumb.
height * scale);
180 IWICImagingFactory *pImgFac;
181 hr = CoCreateInstance(
182 CLSID_WICImagingFactory,
nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pImgFac));
185 hr = pImgFac->CreateBitmapFromHBITMAP(*phbmp, 0, WICBitmapUseAlpha, &WICBmp);
188 bmi.bmiHeader.biSize =
sizeof(bmi.bmiHeader);
189 bmi.bmiHeader.biWidth = NewWidth;
190 bmi.bmiHeader.biHeight = -NewHeight;
191 bmi.bmiHeader.biPlanes = 1;
192 bmi.bmiHeader.biBitCount = 32;
193 bmi.bmiHeader.biCompression = BI_RGB;
196 HBITMAP ResizedHBmp = CreateDIBSection(
197 nullptr, &bmi, DIB_RGB_COLORS, (
void **)&pBits,
nullptr, 0);
198 hr = ResizedHBmp ? S_OK : E_OUTOFMEMORY;
200 IWICBitmapScaler *pIScaler;
201 hr = pImgFac->CreateBitmapScaler(&pIScaler);
202 hr = pIScaler->Initialize(WICBmp, NewWidth, NewHeight, WICBitmapInterpolationModeFant);
204 WICRect rect = {0, 0, NewWidth, NewHeight};
205 hr = pIScaler->CopyPixels(&rect, NewWidth * 4, NewWidth * NewHeight * 4, pBits);
208 DeleteObject(*phbmp);
209 *phbmp = ResizedHBmp;
212 DeleteObject(ResizedHBmp);