Ejemplo n.º 1
0
static bool WREGetAndPasteHBITMAP( WREClipFormat *fmt )
{
    HBITMAP             hbitmap;
    void                *data;
    uint_32             dsize;
    bool                ok;

    data = NULL;

    ok = (fmt != NULL);

    if( ok ) {
        hbitmap = (HBITMAP)GetClipboardData( fmt->fmt );
        ok = (hbitmap != (HBITMAP)NULL);
    }

    if( ok ) {
        ok = WRWriteBitmapToData( hbitmap, (BYTE **)&data, &dsize );
    }

    if( ok ) {
        ok = WRStripBitmapFileHeader( (BYTE **)&data, &dsize );
    }

    if( ok ) {
        ok = WREGetAndPasteBitmap( fmt, data, dsize );
    }

    if( !ok ) {
        if( data != NULL ) {
            WRMemFree( data );
        }
    }

    return( ok );
}
Ejemplo n.º 2
0
Bool WREStripBitmapFileHeader( BYTE **data, uint_32 *size )
{
    return( WRStripBitmapFileHeader( data, size ) );
}
Ejemplo n.º 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 );
}