Exemple #1
0
/*
 * readInBitmapFile - read in the bitmap file, initialize the draw area and
 *                    the view window
 */
static BOOL readInBitmapFile( char *fullname )
{
    bitmap_info         bmi;
    HBITMAP             hbitmap;
    HCURSOR             prevcursor;

    prevcursor = SetCursor( LoadCursor( NULL, IDC_WAIT ) );
    hbitmap = ReadBitmapFile( HMainWindow, fullname, &bmi );
    SetCursor( prevcursor );

    if( hbitmap == (HBITMAP)NULL ) {
        if( bmi.u.bm_info != NULL && bmi.u.bm_info->bmiHeader.biBitCount > 32 ) { /* Was 8 */
            WImgEditError( WIE_ERR_TOO_MANY_COLORS, fullname );
        } else {
            WImgEditError( WIE_ERR_BAD_BITMAP_FILE, fullname );
        }
        if( bmi.u.bm_info != NULL ) {
            MemFree( bmi.u.bm_info );
        }
        return( FALSE );
    }

    return( doReadInBitmapFile( hbitmap, &bmi, fullname, NULL, NULL ) );

} /* readInBitmapFile */
Exemple #2
0
HBITMAP RequestBitmapFile( void )
{
    char                file_name[ _MAX_PATH ];
    HBITMAP             bitmap = 0;

    if( GetFileName( "Open Bitmap", FALSE, "*.BMP",
                                file_name, _MAX_PATH ) ) {
        bitmap = ReadBitmapFile( WinHandle, file_name );
    }
    return( bitmap );
} /*RequestBitmapFile */
Exemple #3
0
/*
 * AddBitmapToToolBar - add a toolbar item ([temp], bitmap, help & command)
 */
vi_rc AddBitmapToToolBar( const char *data )
{
    char                file[FILENAME_MAX];
    char                help[MAX_STR];
    char                dont_save[MAX_STR];
    tool_item           *item;
    int                 cmd_len;
    int                 name_len;

    dont_save[0] = 0;

    data = SkipLeadingSpaces( data );
    if( strnicmp( data, "temp", 4 ) == 0 ) {
        /* get to the command */
        GetStringWithPossibleQuote( &data, dont_save );
    }

    GetStringWithPossibleQuote( &data, file );
    GetStringWithPossibleQuote( &data, help );

    data = SkipLeadingSpaces( data );
    cmd_len = strlen( data );
    name_len = strlen( file );
    item = MemAlloc( sizeof( tool_item ) + cmd_len + name_len + strlen( help ) + 2 );
    strcpy( item->cmd, data );
    if( name_len != 0 ) {
        item->id = NextMenuId();
    } else {
        item->is_blank = true;
    }
    item->dont_save = ( strlen( dont_save ) != 0 );

    if( file[0] && item->cmd[0] ) {
        item->bmp = LoadBitmap( InstanceHandle, file );
        if( item->bmp == HNULL ) {
            item->bmp = ReadBitmapFile( ToolBarWindow( toolBar ), file, NULL );
        }
        item->name = &item->cmd[cmd_len + 1];
        strcpy( item->name, file );
        item->help = &item->name[name_len + 1];
        strcpy( item->help, help );
    } else {
        item->bmp = HNULL;
    }
    if( toolBar ) {
        addToolBarItem( item );
    }
    AddLLItemAtEnd( &toolBarHead, &toolBarTail, &item->tool_head );
    return( ERR_NO_ERR );

} /* AddBitmapToToolBar */