Beispiel #1
0
Bool WREAddBitmapFileHeader( BYTE **data, uint_32 *size )
{
    return( WRAddBitmapFileHeader( data, size ) );
}
Beispiel #2
0
/*
 * readInResourceFile
 */
static bool readInResourceFile( char *fullname )
{
    BYTE                *data;
    uint_32             dsize;
    WRInfo              *info;
    WRSelectImageInfo   *sii;
    WPI_PROC            cb;
    bool                ok;

    info = NULL;
    sii = NULL;
    data = NULL;
    ok = (fullname != NULL);

    if( ok ) {
        info = WRLoadResource( fullname, WR_DONT_KNOW );
        ok = (info != NULL);
    }

    if( ok ) {
        cb = _wpi_makeprocinstance( (WPI_PROC)IEHelpCallBack, Instance );
        sii = WRSelectImage( HMainWindow, info, cb );
        _wpi_freeprocinstance( cb );
        ok = (sii != NULL && sii->lnode != NULL);
    }

    if( ok ) {
        if( sii->type == (uint_16)(pointer_int)RT_BITMAP ) {
            imgType = BITMAP_IMG;
            data = WRCopyResData( info, sii->lnode );
            dsize = sii->lnode->Info.Length;
            ok = (data != NULL);
            if( ok ) {
                ok = WRAddBitmapFileHeader( &data, &dsize );
            }
        } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_CURSOR ) {
            imgType = CURSOR_IMG;
            ok = WRCreateCursorData( info, sii->lnode, &data, &dsize );
        } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_ICON ) {
            imgType = ICON_IMG;
            ok = WRCreateIconData( info, sii->lnode, &data, &dsize );
        } else {
            imgType = UNDEF_IMG;
            ok = false;
        }
    }

    if( ok ) {
        if( sii->type == (uint_16)(pointer_int)RT_BITMAP ) {
            ok = ReadBitmapFromData( data, fullname, info, sii->lnode );
        } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_CURSOR ) {
            ok = ReadCursorFromData( data, fullname, info, sii->lnode );
        } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_ICON ) {
            ok = ReadIconFromData( data, fullname, info, sii->lnode );
        }
    }

    if( sii != NULL ) {
        WRFreeSelectImageInfo( sii );
    }

    if( data != NULL ) {
        MemFree( data );
    }

    return( ok );

} /* readInResourceFile */
Beispiel #3
0
int WRSaveBitmapResource( WRInfo *info, int backup )
{
    int                 ok;
    WResTypeNode        *tnode;
    WResLangNode        *lnode;
    BYTE                *data;
    uint_32             dsize;

    ok = ( info && info->dir );

    if( ok ) {
        tnode = WRFindTypeNode( info->dir, (uint_16)RT_BITMAP, NULL );
        ok = ( tnode != NULL );
        if( !ok ) {
            WRDisplayErrorMsg( WR_PRJNOBMP );
        }
    }

    if( ok ) {
        ok = ((info->dir->NumTypes == 1) && (info->dir->NumResources == 1));
        if( !ok ) {
            WRDisplayErrorMsg( WR_PRJMORETHANONE );
        }
    }

    if( ok ) {
        lnode = NULL;
        if( tnode->Head && tnode->Head->Head ) {
            lnode = tnode->Head->Head;
        }
        ok = ( lnode != NULL );
    }

    if( ok ) {
        if( lnode->data == NULL ) {
            lnode->data = WRLoadResData( info->file_name, lnode->Info.Offset,
                                         lnode->Info.Length );
        }
        ok = ( lnode->data && lnode->Info.Length );
    }

    if( ok ) {
        data = lnode->data;
        dsize = lnode->Info.Length;
        ok = WRAddBitmapFileHeader( &data, &dsize );
    }

    if( ok ) {
        lnode->data = data;
        lnode->Info.Length = dsize;
        ok = WRSaveImageToFile( info, tnode, backup );
    }

    if( ok ) {
        data = lnode->data;
        dsize = lnode->Info.Length;
        ok = WRStripBitmapFileHeader( &data, &dsize );
    }

    if( ok ) {
        lnode->data = data;
        lnode->Info.Length = dsize;
    }

    return( ok );
}