Didn't get the time to find the code athome yesterday, but fortunately I
found a piece of code here at work which is roughly the same code.
I rewrote it a little, but I'm not able to recompile it here. If there's
something wrong with it, it should be simple to fix though.
regards,
Bj�rn
Michael Kaply wrote:
> Great!
>
> I was looking for you. IBM has this new thing where old email gets deleted after 3
> months.
>
> Needless to say, I lost it. :)
>
> Could you please send it to me again. I have some time to spend on it.
>
> Thank you very much!
>
> Mike
>
> Bj�rn Andersson wrote:
>
>
>>I sent you the code for this some months ago.
>>
>>If you don't have it, you can easily pick it up from the toolkits
>>example projects. I think it came from the Jigsaw program. I can't look
>>it up right now, since I'm at work using a Windows machine.
>>
>>The code I gave you was extracted from this, but put in a separate
>>function for convenience. I still have it if you want me to resend it
>>when I get back home.
>>
>>regards,
>>Bj�rn Andersson
>>
>>Michael Kaply wrote:
>>
>>>Warpzilla is the project.
>>>
>>>Mozilla is the browser.
>>>
>>>In order to maintain consistency with other version of Mozilla, I gave us the
>>>same splash screen and icons.
>>>
>>>On Windows, it is very easy to have your own splash screen because Windows has
>>>an API that will create a Windows HBMP from a file on the disk.
>>>
>>>If anyone has an OS/2 API like WinLoadBitmapFromFile, I can add this
>>>functionality to the OS/2 browser.
>>>
>>>Mike
>>>
>>>Walter Meinl wrote:
>>>
>>>
>>>
>>>>Hi,
>>>>since RC2 the splash screen changed from the OS/2 Warpzilla in blue back
>>>>to the red Mozilla screen also used in the windows builds. That also
>>>>happened to the trunk builds some days ago.
>>>>Was this intended by some reason or is it due to my systemm (I am
>>>>sharing my user Profile with a win32 version)?
>>>>For sure its only a minor issue however I liked the Warpzilla sreen so much.
>>>>Regards Walter
>>>
>>>
>
/******************************************************************************/
/* readBitmap: Loads a bitmap from a file. */
/* Extracted from IBM example code */
HBITMAP loadBitmap( char *fileName )
{
APIRET rc; /* API return code */
BOOL fRet = FALSE; /* Function return code. */
PBITMAPFILEHEADER2 pbfh2; /* can address any file types */
PBITMAPINFOHEADER2 pbmp2; /* address any info headers */
PBYTE pFileBegin = NULL; /* beginning of bitmap file data */
ULONG cbRead; /* Number of bytes read by DosRead. */
ULONG cScans, cScansRet, width; /* number of scan lines in bitmap (cy) */
BITMAPINFOHEADER2 bmp2BitmapFile;
PBITMAPINFOHEADER2 pbmp2BitmapFile = &bmp2BitmapFile;
FILE *f = fopen( fileName, "rb" );
HBITMAP hbmBitmap;
if( f == NULL ) return NULL;
/*
* Use Loop to avoid duplicate cleanup code. If any errors, a break
* statement will jump directly to error cleanup code.
*/
do
{
/*
* Find out how big the file is, allocate that much memory, and read
* in the entire bitmap.
*/
fseek( f, 0, SEEK_END );
int fileSize = ftell( f );
fseek( f, 0, SEEK_SET );
pFileBegin = (PBYTE)malloc( fileSize );
cbRead = fread( (PVOID)pFileBegin, fileSize, 1, f );
fclose( f );
/*
* If it's a bitmap-array, point to common file header. Otherwise,
* point to beginning of file.
*/
pbfh2 = (PBITMAPFILEHEADER2) pFileBegin;
pbmp2 = NULL; /* only set this when we validate type */
switch (pbfh2->usType)
{
case BFT_BITMAPARRAY:
/*
* If this is a Bitmap-Array, adjust pointer to the normal
* file header. We'll just use the first bitmap in the
* array and ignore other device forms.
*/
pbfh2 = &(((PBITMAPARRAYFILEHEADER2) pFileBegin)->bfh2);
pbmp2 = &pbfh2->bmp2; /* pointer to info header (readability) */
break;
case BFT_BMAP:
pbmp2 = &pbfh2->bmp2; /* pointer to info header (readability) */
break;
default: /* these formats aren't supported; don't set any ptrs */
case BFT_ICON:
case BFT_POINTER:
case BFT_COLORICON:
case BFT_COLORPOINTER:
break;
} /* end switch (pbfh2->usType) */
if (pbmp2 == NULL)
break; /* File format NOT SUPPORTED: break out to error code */
/*
* Check to see if BMP file has an old structure, a new structure, or
* Windows structure. Capture the common data and treat all bitmaps
* generically with pointer to new format. API's will determine format
* using cbFixed field.
*
* Windows bitmaps have the new format, but with less data fields
* than PM. The old strucuture has some different size fields,
* though the field names are the same.
*
*
* NOTE: bitmap data is located by offsetting the beginning of the file
* by the offset contained in pbfh2->offBits. This value is in
* the same relatie location for different format bitmap files.
*/
if (pbmp2->cbFix == sizeof(BITMAPINFOHEADER)) /* old format? */
{
width = (ULONG) ((PBITMAPINFOHEADER)pbmp2)->cx;
cScans = (ULONG) ((PBITMAPINFOHEADER)pbmp2)->cy;
}
else /* new PM format, Windows, or other */
{
width = pbmp2->cx;
cScans = pbmp2->cy;
}
memcpy( /* copy bitmap info into global structure */
(PVOID) pbmp2BitmapFile,
(PVOID) pbmp2,
pbmp2->cbFix); /* only copy specified size (varies per format) */
hbmBitmap =
GpiCreateBitmap(
hps, /* presentation-space handle */
pbmp2BitmapFile, /* address of structure for format data */
0L, /* options */
NULL, /* address of buffer of image data */
NULL); /* address of structure for color and format */
if (!hbmBitmap)
break; /* jump to error code outside of loop */
if (GpiSetBitmap( hps, hbmBitmap) == (HBITMAP)BMB_ERROR)
break; /* jump to error code outside of loop */
/*
* Tell GPI to put the bits into the thread's PS. The function returns
* the number of scan lines of the bitmap that were copied. We want
* all of them at once.
*/
cScansRet =
GpiSetBitmapBits(
hps, /* presentation-space handle */
0L, /* index of first scan line */
cScans, /* number of scan lines */
pFileBegin + pbfh2->offBits, /* address of bitmap data */
(PBITMAPINFO2) pbmp2); /* address of bitmap header table */
if (cScansRet != cScans) /* original # of scans? */
break; /* jump to error code outside of loop */
free( pFileBegin);
return hbmBitmap;
} while (FALSE); /* fall through loop first time */
/*
* Close the file, free the buffer space and leave. This is an error exit
* point from the function. Cleanup code is here to avoid duplicate code
* after each operation.
*/
if (pFileBegin != NULL)
free( pFileBegin);
return NULL; /* function failed */
// Remove "variable assigned a value that is never used" warning.
#pragma warn -aus
} /* end ReadBitmap() */
#pragma warn +aus