1
//-----------------------------------------------------------------------------
3
// ImageLib Utility Toolkit Sources
4
// Copyright (C) 2000-2002 by Denton Woods
5
// Last modified: 05/28/2001 <--Y2K Compliant! =]
7
// Filename: src-ILUT/src/ilut_win32.c
9
// Description: Windows functions for images
11
//-----------------------------------------------------------------------------
14
#include "ilut_internal.h"
19
// For ilutWinLoadUrl().
20
//pragma comment(lib, "wininet.lib")
22
#if !_WIN32_WCE && (_WIN32 && __GNUC__)
26
ILboolean ilutWin32Init()
34
ILAPI HBITMAP ILAPIENTRY ilutConvertSliceToHBitmap(HDC hDC, ILuint slice)
36
ILubyte *Data, *DataBackup;
39
ILuint pad, i, j, k, l, m, n, DepthBackup;
41
ILboolean alloc_buffer;
43
//reserve space for palette in every case...
44
ILubyte *buff[sizeof(BITMAPINFOHEADER) + 256*sizeof(RGBQUAD)];
45
BITMAPINFO *info = (BITMAPINFO*)buff;
46
RGBQUAD *pal = info->bmiColors;
48
ilutCurImage = ilutCurImage = ilGetCurImage();
49
if (ilutCurImage == NULL) {
50
ilSetError(ILUT_ILLEGAL_OPERATION);
54
//check if the image has the wanted slice
55
if (slice < 0 || slice >= ilutCurImage->Depth) {
56
ilSetError(ILUT_INVALID_PARAM);
60
//fool iConvertImage into thinking that the current image has
61
//only one slice, the one we want:
62
DepthBackup = ilutCurImage->Depth;
63
DataBackup = ilutCurImage->Data;
64
ilutCurImage->Depth = 1;
65
ilutCurImage->Data += ilutCurImage->SizeOfPlane*slice;
67
if (ilutCurImage->Type != IL_UNSIGNED_BYTE)
68
TempImage = iConvertImage(ilutCurImage, ilutCurImage->Format, IL_UNSIGNED_BYTE);
70
TempImage = ilutCurImage;
71
if (TempImage == NULL)
74
//changed 2003-09-09: use Temp!
75
ilSetCurImage(TempImage);
77
hBitmap = CreateCompatibleBitmap(hDC, ilutCurImage->Width, ilutCurImage->Height);
79
ilSetError(IL_UNKNOWN_ERROR);
83
info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
84
info->bmiHeader.biWidth = TempImage->Width;
85
if(TempImage->Origin == IL_ORIGIN_UPPER_LEFT)
86
info->bmiHeader.biHeight = -(ILint)TempImage->Height;
88
info->bmiHeader.biHeight = TempImage->Height;
89
info->bmiHeader.biPlanes = 1;
90
info->bmiHeader.biCompression = 0;
91
info->bmiHeader.biSizeImage = 0;
92
info->bmiHeader.biXPelsPerMeter = 0;
93
info->bmiHeader.biYPelsPerMeter = 0;
94
info->bmiHeader.biClrUsed = 0;
95
info->bmiHeader.biClrImportant = 0;
97
pad = (4 - TempImage->Bps%4)%4;
98
alloc_buffer = !(pad == 0 && TempImage->Format != IL_RGB
99
&& TempImage->Format != IL_RGBA && TempImage->Format != IL_LUMINANCE_ALPHA);
101
Data = TempImage->Data;
104
if (TempImage->Format == IL_RGBA) {//strip alpha during byte swapping for faster upload to gdi
105
//recalculate pad because it changes when bpp change
106
pad = (4 - (3*TempImage->Width)%4)%4;
107
Data = ialloc((TempImage->Width + pad)*TempImage->Height*3);
109
//strip alpha channel from grayscale image
110
else if(TempImage->Format == IL_LUMINANCE_ALPHA)
111
Data = ialloc((TempImage->Width + pad)*TempImage->Height);
113
Data = ialloc((TempImage->Width + pad)*TempImage->Height*TempImage->Bpp);
116
ilSetCurImage(ilutCurImage);
117
ilCloseImage(TempImage);
118
ilSetError(IL_OUT_OF_MEMORY);
122
if (TempImage->Format == IL_RGB || TempImage->Format == IL_RGBA) {
124
m = (TempImage->Format == IL_RGB)?3:4;
126
for (j = 0; j < TempImage->Height; j++) {
127
for (i = 0, n = 0; i < 3*TempImage->Width; i += 3, n += m) {
128
Data[l + i] = TempImage->Data[k + n + 2];
129
Data[l + i + 1] = TempImage->Data[k + n + 1];
130
Data[l + i + 2] = TempImage->Data[k + n];
134
l += 3*TempImage->Width + pad;
137
else if(TempImage->Format == IL_LUMINANCE_ALPHA) {
138
//strip alpha channel
140
for (j = 0; j < TempImage->Height; j++) {
141
for (i = 0, n = 0; i < TempImage->Width; ++i, n += 2) {
142
Data[l + i] = TempImage->Data[k + n];
145
l += TempImage->Width + pad;
149
for (i = 0; i < TempImage->Height; i++)
150
memcpy(Data + i*(TempImage->Bps + pad), TempImage->Data + i*TempImage->Bps, TempImage->Bps);
153
switch(TempImage->Format) {
156
case IL_LUMINANCE_ALPHA:
157
case IL_COLOUR_INDEX:
158
if (TempImage->Format != IL_COLOUR_INDEX) {
159
//generate greyscale palette
160
for (i = 0; i < 256; i++)
161
pal[i].rgbRed = pal[i].rgbGreen = pal[i].rgbBlue = i;
164
palImg = iConvertPal(&TempImage->Pal, IL_PAL_BGR32);
165
if (palImg != NULL) {
166
memcpy(pal, palImg->Palette, palImg->PalSize);
170
ilSetError(IL_INVALID_PARAM);
171
//generate greyscale palette
172
for (i = 0; i < 256; i++)
173
pal[i].rgbRed = pal[i].rgbGreen = pal[i].rgbBlue = i;
176
info->bmiHeader.biBitCount = 8;
181
case IL_RGBA: //alpha is removed during byte swapping
182
info->bmiHeader.biBitCount = 24;
186
info->bmiHeader.biBitCount = 32;
190
ilSetError(IL_FORMAT_NOT_SUPPORTED);
194
if (ilutCurImage != TempImage) {
195
ilSetCurImage(ilutCurImage);
196
ilCloseImage(TempImage);
199
//restore original data
200
ilutCurImage->Data = DataBackup;
201
ilutCurImage->Depth = DepthBackup;
203
SetDIBits(hDC, hBitmap, 0, ilutCurImage->Height, Data, info, DIB_RGB_COLORS);
211
HBITMAP ILAPIENTRY ilutConvertToHBitmap(HDC hDC)
213
return ilutConvertSliceToHBitmap(hDC, 0);
216
ILubyte* ILAPIENTRY iGetPaddedData(ILimage *Image)
218
ILubyte *NewData = NULL, *TempBuff = NULL;
219
ILuint i, CurPos = 0, PadSize;
220
ILubyte *TempData = NULL;
223
ilSetError(ILUT_INVALID_PARAM);
227
if (Image->Origin != IL_ORIGIN_LOWER_LEFT) {
228
TempData = iGetFlipped(Image);
231
TempData = Image->Data;
234
if (Image->Format == IL_RGB || Image->Format == IL_RGBA) {
235
TempBuff = (ILubyte*)ialloc(Image->SizeOfData);
236
if (TempBuff == NULL) {
239
// Swap red and blue.
240
for (i = 0; i < Image->SizeOfData; i += Image->Bpp) {
241
TempBuff[i] = TempData[i+2];
242
TempBuff[i+1] = TempData[i+1];
243
TempBuff[i+2] = TempData[i];
250
PadSize = (4 - (Image->Bps % 4)) % 4;
251
NewData = (ILubyte*)ialloc((Image->Width + PadSize) * Image->Height * Image->Bpp);
252
if (NewData == NULL) {
256
for (i = 0; i < Image->Height; i++) {
257
memcpy(NewData + CurPos, TempBuff + Image->Bps * i, Image->Bps);
258
CurPos += Image->Bps;
259
memset(NewData + CurPos, 0, PadSize);
263
if (TempData != TempBuff && TempData != Image->Data)
265
if (TempBuff != Image->Data)
272
ILvoid ILAPIENTRY ilutFreePaddedData(ILubyte *Data)
279
// DirectX/GDI insists that all scanlines end on a dword boundary. =(
280
ILubyte* ILAPIENTRY ilutGetPaddedData()
282
return iGetPaddedData(ilGetCurImage());
286
// @TODO: Figure how to mess with multiple bpc's!
287
ILvoid ILAPIENTRY ilutGetBmpInfo(BITMAPINFO *Info)
289
ILuint NewBps, Padding;
291
ilutCurImage = ilGetCurImage();
292
if (ilutCurImage == NULL) {
293
ilSetError(ILUT_ILLEGAL_OPERATION);
297
Padding = (4 - (ilutCurImage->Bps % 4)) % 4;
298
NewBps = ilutCurImage->Bps/* + Padding*/;
300
Info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
301
Info->bmiHeader.biWidth = ilutCurImage->Width;
302
Info->bmiHeader.biHeight = ilutCurImage->Height;
303
Info->bmiHeader.biPlanes = 1;
304
Info->bmiHeader.biBitCount = ilutCurImage->Bpp << 3;
305
Info->bmiHeader.biCompression = BI_RGB;
306
Info->bmiHeader.biSizeImage = NewBps * ilutCurImage->Height;
307
Info->bmiHeader.biXPelsPerMeter = 0;
308
Info->bmiHeader.biYPelsPerMeter = 0;
309
Info->bmiHeader.biClrUsed = ilutCurImage->Bpp == 1 ? 255 : 0;
310
if (Info->bmiHeader.biClrUsed < 24)
311
Info->bmiHeader.biClrImportant = Info->bmiHeader.biClrUsed;
313
Info->bmiHeader.biClrImportant = 0;
319
//! Just a convenience function.
320
HBITMAP ILAPIENTRY ilutWinLoadImage(const ILstring FileName, HDC hDC)
325
if (!ilLoadImage(FileName))
328
Bitmap = ilutConvertToHBitmap(hDC);
335
ILboolean ILAPIENTRY ilutWinSaveImage(const ILstring FileName, HBITMAP Bitmap)
340
CurName = ilGetCurName();
344
if (!ilutSetHBitmap(Bitmap)) {
345
ilBindImage(CurName);
349
Saved = ilSaveImage(FileName);
350
ilBindImage(CurName);
357
// @TODO: Just create a copy of the palette!
358
// Credit for this goes to the OpenGL SuperBible.
359
HPALETTE ILAPIENTRY ilutGetHPal()
363
ILuint NumEntries, i;
366
ilutCurImage = ilGetCurImage();
367
if (ilutCurImage == NULL) {
368
ilSetError(ILUT_ILLEGAL_OPERATION);
372
if (!ilutCurImage->Pal.Palette || !ilutCurImage->Pal.PalSize || ilutCurImage->Pal.PalType == IL_PAL_NONE) {
373
//ilSetError(ILUT_ILLEGAL_OPERATION);
377
CurPalType = ilutCurImage->Pal.PalType;
378
if (!ilConvertPal(IL_PAL_RGB24)) {
379
return NULL; // ilConvertPal already sets the error
381
NumEntries = ilutCurImage->Pal.PalSize / 3;
383
LogPal = (LOGPALETTE*)ialloc(sizeof(LOGPALETTE) + NumEntries * sizeof(PALETTEENTRY));
388
LogPal->palVersion = 0x300;
389
LogPal->palNumEntries = NumEntries;
391
for (i = 0; i < NumEntries; i++) {
392
LogPal->palPalEntry[i].peRed = ilutCurImage->Pal.Palette[i * 3];
393
LogPal->palPalEntry[i].peGreen = ilutCurImage->Pal.Palette[i * 3 + 1];
394
LogPal->palPalEntry[i].peBlue = ilutCurImage->Pal.Palette[i * 3 + 2];
395
LogPal->palPalEntry[i].peFlags = 0;
398
Palette = CreatePalette(LogPal);
401
ilConvertPal(CurPalType); // Should we check the return value?
407
ILboolean ILAPIENTRY ilutSetHBitmap(HBITMAP Bitmap)
413
ILubyte *Buffer1 = NULL, *Buffer2 = NULL;
414
ILuint i, j, PadSize, Bps;
416
ilutCurImage = ilGetCurImage();
417
if (ilutCurImage == NULL) {
418
ilSetError(ILUT_ILLEGAL_OPERATION);
422
hWnd = GetForegroundWindow();
425
// Query the dimensions
426
memset(&Info, 0, sizeof(BITMAPINFO));
427
Info[0].bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
428
GetDIBits(hDC, Bitmap, 0, 0, NULL, Info, DIB_RGB_COLORS);
430
// @TODO: Implement this shitz0rz!
431
if (Info[0].bmiHeader.biBitCount < 24) {
432
ReleaseDC(hWnd, hDC); //added 20040527
436
Buffer1 = (ILubyte*)ialloc(Info[0].bmiHeader.biSizeImage);
437
Buffer2 = (ILubyte*)ialloc(Info[0].bmiHeader.biSizeImage);
438
if (Buffer1 == NULL || Buffer2 == NULL) {
439
ReleaseDC(hWnd, hDC); //added 20040527
446
GetDIBits(hDC, Bitmap, 0, Info[0].bmiHeader.biHeight, Buffer1, Info, DIB_RGB_COLORS);
448
Bps = Info[0].bmiHeader.biWidth * (Info[0].bmiHeader.biBitCount >> 3);
449
PadSize = (4 - (Bps % 4)) % 4;
451
// Remove the padding.
452
for (i = 0, j = 0; i < Info[0].bmiHeader.biSizeImage; i += Bps + PadSize, j += Bps) {
453
memcpy(Buffer2 + j, Buffer1 + i, Bps);
456
if (Info[0].bmiHeader.biBitCount == 24) {
457
ilTexImage(Info[0].bmiHeader.biWidth, Info[0].bmiHeader.biHeight, 1,
458
(ILubyte)(Info[0].bmiHeader.biBitCount >> 3), IL_BGR, IL_UNSIGNED_BYTE, Buffer2);
460
else if (Info[0].bmiHeader.biBitCount == 32) {
461
ilTexImage(Info[0].bmiHeader.biWidth, Info[0].bmiHeader.biHeight, 1,
462
(ILubyte)(Info[0].bmiHeader.biBitCount >> 3), IL_BGRA, IL_UNSIGNED_BYTE, Buffer2);
464
ilutCurImage->Origin = IL_ORIGIN_LOWER_LEFT;
466
ReleaseDC(hWnd, hDC); //added 20040527
476
ILboolean ILAPIENTRY ilutSetHPal(HPALETTE Pal)
478
LPPALETTEENTRY PalEntries;
479
ILuint NumEntries, i;
482
ilutCurImage = ilGetCurImage();
483
if (ilutCurImage == NULL) {
484
ilSetError(ILUT_ILLEGAL_OPERATION);
488
NumEntries = GetPaletteEntries(Pal, 0, 0, NULL);
490
return IL_TRUE; // @TODO: Determine if correct...
492
PalEntries = (LPPALETTEENTRY)ialloc(NumEntries * sizeof(PALETTEENTRY));
493
if (PalEntries == NULL) {
497
NumEntries = GetPaletteEntries(Pal, 0, NumEntries, PalEntries);
499
TempPal = (ILubyte*)ialloc(NumEntries * 3);
500
if (TempPal == NULL) {
504
if (ilutCurImage->Pal.Palette)
505
ifree(ilutCurImage->Pal.Palette);
506
ilutCurImage->Pal.Palette = TempPal;
507
ilutCurImage->Pal.PalSize = NumEntries * 3;
508
ilutCurImage->Pal.PalType = IL_PAL_RGB24;
510
for (i = 0; i < NumEntries; i++) {
511
*TempPal++ = PalEntries[i].peRed;
512
*TempPal++ = PalEntries[i].peGreen;
513
*TempPal++ = PalEntries[i].peBlue;
522
ILboolean ILAPIENTRY ilutSetWinClipboard()
528
ILimage *TempImage, *CurImage;
530
ilutCurImage = ilGetCurImage();
531
if (ilutCurImage == NULL) {
532
ilSetError(ILUT_ILLEGAL_OPERATION);
536
if (ilutCurImage->Format != IL_BGR || ilutCurImage->Bps > 1) {
537
TempImage = iConvertImage(ilutCurImage, IL_BGR, IL_UNSIGNED_BYTE);
538
if (TempImage == NULL)
542
TempImage = ilutCurImage;
544
CurImage = ilutCurImage;
545
ilSetCurImage(TempImage);
547
hWnd = GetForegroundWindow();
550
if (!OpenClipboard(NULL)) {
551
if (TempImage != ilutCurImage)
552
ilCloseImage(TempImage);
553
ilSetCurImage(CurImage);
554
ilSetError(ILUT_ILLEGAL_OPERATION); // Dunno if this is the correct error.
555
ReleaseDC(hWnd, hDC); //added 20040604
556
if (TempImage != ilutCurImage)
557
ilCloseImage(TempImage);
558
ilSetCurImage(CurImage);
562
//note that this is not the best method to put an image into the
563
//clipboard, CF_DIB is much better because HBITMAPS are device-dependent.
564
//TODO: eventually change that if there is a need
565
Bitmap = ilutConvertToHBitmap(hDC);
566
ReleaseDC(hWnd, hDC); //added 20040604
569
Handle = SetClipboardData(CF_BITMAP, Bitmap);
573
//DeleteObject(Bitmap); // Needed? No! Clipboard takes care of image.
575
if (TempImage != ilutCurImage)
576
ilCloseImage(TempImage);
577
ilSetCurImage(CurImage);
583
ILboolean ILAPIENTRY ilutGetWinClipboard()
589
BITMAPFILEHEADER *BmpHeader;
590
BITMAPINFOHEADER *InfoHeader;
593
ilutCurImage = ilGetCurImage();
594
if (ilutCurImage == NULL) {
595
ilSetError(ILUT_ILLEGAL_OPERATION);
599
if (IsClipboardFormatAvailable(CF_DIB)) {
600
hWnd = GetForegroundWindow();
602
if (!OpenClipboard(hWnd)) {
603
ilSetError(ILUT_ILLEGAL_OPERATION); // Dunno if this is the correct error.
607
hGlobal = GetClipboardData(CF_DIB);
610
return IL_FALSE; // No error?
613
//copy DIB to buffer because windows delivers it without the
614
//BITMAPFILEHEADER that DevIL needs to load the image
615
Size = GlobalSize(hGlobal);
616
data = ialloc(Size + sizeof(BITMAPFILEHEADER));
617
pGlobal = GlobalLock(hGlobal);
618
if (!pGlobal || !data) {
621
return IL_FALSE; // No error?
623
memcpy(data + sizeof(BITMAPFILEHEADER), pGlobal, Size);
624
GlobalUnlock(hGlobal);
627
//create BITMAPFILEHEADER
628
InfoHeader = (BITMAPINFOHEADER*)(data + sizeof(BITMAPFILEHEADER));
629
BmpHeader = (BITMAPFILEHEADER*)data;
630
BmpHeader->bfType = 'B' | ('M' << 8);
631
BmpHeader->bfSize = Size + sizeof(BITMAPFILEHEADER);
632
BmpHeader->bfReserved1 = BmpHeader->bfReserved2 = 0;
633
BmpHeader->bfOffBits = sizeof(BITMAPFILEHEADER) + InfoHeader->biSize + InfoHeader->biClrUsed*4;
634
if (InfoHeader->biCompression == BI_BITFIELDS)
635
BmpHeader->bfOffBits += 12;
637
return ilLoadL(IL_BMP, data, BmpHeader->bfSize);
640
//this is not required becaus CF_BITMAP is converted to CF_DIB automatically
641
//when needed. CF_DIB suffices.
642
else if (IsClipboardFormatAvailable(CF_BITMAP)) {
643
hWnd = GetForegroundWindow();
645
if (!OpenClipboard(hWnd)) {
646
ilSetError(ILUT_ILLEGAL_OPERATION); // Dunno if this is the correct error.
650
Bitmap = (HBITMAP)GetClipboardData(CF_BITMAP);
653
return IL_FALSE; // No error?
656
if (!ilutSetHBitmap(Bitmap)) {
663
else { //no data in clipboard
664
ilSetError(ILUT_ILLEGAL_OPERATION);
672
ILboolean ILAPIENTRY ilutWinPrint(ILuint XPos, ILuint YPos, ILuint Width, ILuint Height, HDC hDC)
674
#if !defined(_WIN32_WCE) && !(defined(_WIN32) && defined(__GNUC__))
677
HBITMAP Bitmap, hReplaced;
680
ilutCurImage = ilGetCurImage();
681
if (ilutCurImage == NULL) {
682
ilSetError(ILUT_ILLEGAL_OPERATION);
686
// Needs error checking!
687
hMemDC = CreateCompatibleDC(hDC);
688
Bitmap = ilutConvertToHBitmap(hDC);
689
hReplaced = (HBITMAP)SelectObject(hMemDC, Bitmap);
691
memset(&Pd, 0, sizeof(PRINTDLG));
692
Pd.lStructSize = sizeof(PRINTDLG);
693
Pd.hwndOwner = GetForegroundWindow();
694
Pd.Flags = PD_RETURNDC;
696
Pd.nFromPage = 0xFFFF;
699
Pd.nMaxPage = 0xFFFF;
704
Di.cbSize = sizeof(DOCINFO);
705
Di.lpszDocName = "DevIL Print Job";
706
Di.lpszOutput = NULL;
707
Di.lpszDatatype = NULL;
710
StartDoc(Pd.hDC, &Di);
713
StretchBlt(Pd.hDC, XPos, YPos, Width, Height, hMemDC, 0, 0, ilutCurImage->Width, ilutCurImage->Height, SRCCOPY);
717
DeleteObject(Bitmap);
718
DeleteObject(hReplaced);
727
ILboolean ILAPIENTRY ilutLoadResource(HINSTANCE hInst, ILint ID, const ILstring ResourceType, ILenum Type)
729
HRSRC Resource = (HRSRC)LoadResource(hInst, FindResource(hInst, MAKEINTRESOURCE(ID), ResourceType));
730
ILubyte *Data = (ILubyte*)LockResource(Resource);
732
return ilLoadL(Type, Data, SizeofResource(hInst, FindResource(hInst, MAKEINTRESOURCE(ID), ResourceType)));
736
#if !defined(_WIN32_WCE) && !(defined(_WIN32) && defined(__GNUC__))
737
#define BUFFSIZE 8192 // Change to suit the efficiency.
738
ILboolean ILAPIENTRY ilutWinLoadUrl(const ILstring Url)
740
HINTERNET Handle, UrlHandle;
741
DWORD BytesRead = 0, Context = 1;
742
ILubyte Buff[BUFFSIZE], *Buffer, *TempBuff;
743
ILuint BufferSize = 0, i;
744
ILboolean Is404 = IL_TRUE;
745
char Buffer404[] = { '<', 'h', 't', 'm', 'l', '>' };
747
Buffer = (ILubyte*)ialloc(0);
748
if (Buffer == NULL) {
752
Handle = InternetOpen("Developer's Image Library", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
753
if (Handle == NULL) {
755
ilSetError(ILUT_COULD_NOT_OPEN_FILE);
759
// Try again if fails the first time, loading only from the cache.
760
UrlHandle = InternetOpenUrl(Handle, Url, NULL, 0, 0, Context);
761
if (UrlHandle == NULL) {
762
InternetCloseHandle(Handle);
763
Handle = InternetOpen("Developer's Image Library", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_FROM_CACHE);
764
if (Handle == NULL) {
766
ilSetError(ILUT_COULD_NOT_OPEN_FILE);
769
UrlHandle = InternetOpenUrl(Handle, Url, NULL, 0, 0, Context);
770
if (UrlHandle == NULL) {
772
InternetCloseHandle(Handle);
773
ilSetError(ILUT_COULD_NOT_OPEN_FILE);
779
if (!InternetReadFile(UrlHandle, Buff, BUFFSIZE, &BytesRead)) {
780
InternetCloseHandle(UrlHandle);
781
InternetCloseHandle(Handle);
783
ilSetError(ILUT_COULD_NOT_OPEN_FILE);
787
TempBuff = (ILubyte*)ialloc(BufferSize + BytesRead);
788
if (TempBuff == NULL) {
793
memcpy(TempBuff, Buffer, BufferSize);
794
memcpy(TempBuff + BufferSize, Buff, BytesRead);
798
BufferSize += BytesRead;
799
} while (BytesRead > 0);
801
InternetCloseHandle(UrlHandle);
802
InternetCloseHandle(Handle);
804
// If the image does not exist, the server usually returns a 404 HTML page.
805
for (i = 0; i < sizeof(Buffer404) && i < BufferSize; i++) {
806
if (tolower(Buffer[i]) != Buffer404[i]) {
813
if (!ilLoadL(ilTypeFromExt(Url), Buffer, BufferSize)) {
814
if (!ilLoadL(IL_TYPE_UNKNOWN, Buffer, BufferSize)) {
828
#endif//ILUT_USE_WIN32