Ignore:
Timestamp:
Jul 13, 2017, 5:17:57 AM (8 years ago)
Author:
stevenhl
Message:

Import modifications from cwmm-0_2_9-work-01_10_2006.zip dated 2006-08-27

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/common_functions/img_funcs.c

    r2 r4  
    22  This file conatins functions for loading image files.
    33 */
     4
    45#define  INCL_PM
     6#define INCL_OS2MM
    57#define  INCL_MMIOOS2
    68
     
    1820/* This function loads a supported image file.      */
    1921/* Every format for which MMOS2 has an IO procedure */
    20 /* may be used here.                                */
     22/* may be used here. In contrast to                 */
     23/* ImgLoadImageFile() a provided BMPINFOHEADER2     */
     24/* structure is filled with data.                   */
     25/*                                                  */
    2126/*                                                  */
    2227/* @@RETURNS                                        */
     
    2429/* HBITMAP hBitmap                                  */
    2530/*                                                  */
    26 /* HAndle to the bitmap of NULL.                    */
     31/* Handle to the bitmap or NULL.                    */
     32/*                                                  */
     33/* @@PARAM                                          */
     34/*                                                  */
     35/* PSZ pszFileName input                            */
     36/*                                                  */
     37/* Name of the image file to load.                  */
     38/*                                                  */
     39/* @@PARAM                                          */
     40/*                                                  */
     41/* PBITMAPINFOHEADER2 pBMPInfoHeader2 in/out        */
     42/*                                                  */
     43/* Pointer to a BITMAPINFOHEADER2 structure.        */
     44/*                                                  */
     45/*                                                  */
     46/* @@REMARKS                                        */
     47/*                                                  */
     48/* The caller must free the bitmap handle after     */
     49/* use.                                             */
    2750/*                                                  */
    2851/*!!*************************************************/
    29 HBITMAP ImgLoadImageFile (  PSZ pszFileName )
     52HBITMAP ImgLoadImageFileAndHeader( PSZ pszFileName, PBITMAPINFOHEADER2 pBMPInfoHeader2)
    3053{
    3154    HBITMAP       hbm;
    32     HBITMAP       hbmTarget;
    3355    MMIOINFO      mmioinfo;
    34         MMFORMATINFO  mmFormatInfo;
     56    MMFORMATINFO  mmFormatInfo;
    3557    HMMIO         hmmio;
    36         ULONG         ulImageHeaderLength;
    37         MMIMAGEHEADER mmImgHdr;
     58    ULONG         ulImageHeaderLength;
     59    MMIMAGEHEADER mmImgHdr;
    3860    ULONG         ulBytesRead;
    3961    ULONG         dwNumRowBytes;
     
    131153            return (0L);
    132154    }
    133     /*
    134     memcpy(pBMPInfoHeader2, &mmImgHdr.mmXDIBHeader.BMPInfoHeader2,
    135            sizeof(BITMAPINFOHEADER2)+256*sizeof(RGB2) );
    136            */
     155
    137156    /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
     157    *pBMPInfoHeader2=mmImgHdr.mmXDIBHeader.BMPInfoHeader2;
    138158
    139159    /*
     
    226246                            NULL);
    227247
    228 #if 0
    229     hbm = GpiCreateBitmap ( hps,
    230                             pBMPInfoHeader2,
    231                             0L,
    232                             NULL,
    233                             NULL);
    234 #endif
    235 
    236248    if ( !hbm )
    237249    {
     
    250262      return(0L);
    251263    }
    252     /*
    253     // ***************************************************
    254     // Select the bitmap into the memory device context.
    255     // ***************************************************/
     264    /****************************************************
     265      Select the bitmap into the memory device context.
     266      ***************************************************/
    256267    hbReturnCode = GpiSetBitmap ( hps,
    257268                                  hbm );
    258     /*
    259     //***************************************************************
    260     //  LOAD THE BITMAP DATA FROM THE FILE
    261     //      One line at a time, starting from the BOTTOM
    262     //*************************************************************** */
     269    /***************************************************************
     270      LOAD THE BITMAP DATA FROM THE FILE
     271      One line at a time, starting from the BOTTOM
     272      ****************************************************************/
    263273
    264274    for ( dwRowCount = 0; dwRowCount < dwHeight; dwRowCount++ )
     
    294304
    295305
    296 BOOL ImgGetBmpInfoHeader(PBITMAPINFOHEADER2  bmpih2, PSZ pszFileName /*, char* procName, ULONG ulLength*/)
     306/*!**************************************************/
     307/*                                                  */
     308/* @@DESC                                           */
     309/*                                                  */
     310/* This function loads a supported image file.      */
     311/* Every format for which MMOS2 has an IO procedure */
     312/* may be used here.                                */
     313/*                                                  */
     314/* @@PARAM                                          */
     315/*                                                  */
     316/* PSZ pszFileName input                            */
     317/*                                                  */
     318/* Name of the image file to load.                  */
     319/*                                                  */
     320/* @@RETURNS                                        */
     321/*                                                  */
     322/* HBITMAP hBitmap                                  */
     323/*                                                  */
     324/* Handle to the bitmap of NULL.                    */
     325/*                                                  */
     326/*!!*************************************************/
     327HBITMAP ImgLoadImageFile (  PSZ pszFileName )
     328{
     329  BITMAPINFOHEADER2  bmpih2;
     330
     331  return ImgLoadImageFileAndHeader ( pszFileName, &bmpih2 );
     332}
     333
     334
     335
     336/*!**************************************************/
     337/*                                                  */
     338/* @@DESC                                           */
     339/*                                                  */
     340/* Build a BITMAPINFOHEADER2 for the given file.    */
     341/*                                                  */
     342/* @@PARAM                                          */
     343/*                                                  */
     344/* PSZ pszFileName input                            */
     345/*                                                  */
     346/* Name of the image file.                          */
     347/*                                                  */
     348/* @@PARAM                                          */
     349/*                                                  */
     350/* PBITMAPINFOHEADER2 pBMPInfoHeader2 in/out        */
     351/*                                                  */
     352/* Pointer to a BITMAPINFOHEADER2 structure.        */
     353/*                                                  */
     354/* @@RETURNS                                        */
     355/*                                                  */
     356/* TRUE on success, FALSE otherwise                 */
     357/*                                                  */
     358/*!!*************************************************/
     359BOOL ImgGetBmpInfoHeader(PSZ pszFileName, PBITMAPINFOHEADER2  bmpih2)
    297360{
    298361    MMIOINFO      mmioinfo;
     
    305368    ULONG         ulReturnCode;
    306369    ULONG ulBytesRead;
    307     char *pName;
    308370   
    309     //  if(procName)
    310     //   procName[0]=0;
    311 
    312371    /* Check file size */
    313372    if(SysQueryFileSize(pszFileName)==0)
Note: See TracChangeset for help on using the changeset viewer.