[C/C++] bmp Datei speichern mit c-code

Dieses Thema im Forum "Programmierung & Entwicklung" wurde erstellt von Staasi, 21. Januar 2008 .

Status des Themas:
Es sind keine weiteren Antworten möglich.
  1. 21. Januar 2008
    bmp Datei speichern mit c-code

    HUHU, schon wieder ich.


    Also, ich habe ein Programm geschrieben das eine .bmp Datei öffnet, nach Punkten durchsucht und Linien einzeichnet. Das Bild wird mit Paint geöffnet. Problem ist, ich habe keine Ahnung, wie man eine Datei umbenennt (muss nicht unbedingt) und sie dann abspeichert. Hab es mit arrays und strings versucht, aber war total überfordert

    Danke für jede Hilfe!!!


    Hier der Teil wo das ich das machen will, falls ihr das braucht
    PHP:
    void main ( void )
    {
    double breite , hoehe ;
        
    double X [ 2 ][ 2 ], R [ 1 ][ 2 ], Fl , Laengex , Laengey ;
        
    int ier = 1 xz , yz , xta , xte , yta , yte , black = 0 , zaehler = 0 , l = 0 , o = 0 , k , c , t ;
        
    char Dateipfad [ 500 ];

    int pbreite phoehe pixel , r , g , b , x = 0 , y = 0 , br , ho ;




    for(
    t = 0 ; ier == 1 ; t ++)
        {
    printf ( "Bitte geben Sie den Dateipfad der Bitmap-Datei ein: \n" );
    scanf ( "%s" ,& Dateipfad );





        
    ier = bmpRead ( Dateipfad );

        if(
    ier == 1 )

            {
                
    printf ( "\n\n\tDatei nicht gefunden\n\n\n\n\n" );

            }
        if(
    t == 5 )
            {
                
    printf ( "---------------------------------------------------------------------------" );
                
    printf ( "\n\nBitte ueberpruefen sie, ob der Dateipfad und die Datei uebereinstimmen!\n\n" );
                
    printf ( "---------------------------------------------------------------------------" );
                exit(
    0 );
            }

        }



    bmpGetParameters (& breite ,& hoehe ,& pbreite ,& phoehe ,& pixel );

    X [ 0 ][ 0 ]= pbreite ;
    X [ 0 ][ 1 ]= 0 ;
    X [ 1 ][ 0 ]= phoehe ;
    X [ 1 ][ 1 ]= 0 ;
    k = pbreite ;
    c = 0 ;

        for(
    xz = 0 ; xz < pbreite ; xz ++)
            {

            for(
    yz = 0 ; yz < phoehe ; yz ++)

                { 
    bmpGetPixel  ( xz yz , & r , & g , & b );




                        if(
    r > 150  &&  g < 20  &&  b < 20 )
                            {





                                            if (
    xz < k )
                                                {
                                                
    k = xz ;
                                                
    zaehler = 0 ;


                                                }
                                            if (
    xz > c )
                                                {
                                                
    c = xz ;
                                                
    zaehler = 0 ;
                                                }


                            }





                            if(
    r == &&  g == &&  b == 0 )
                            {


                                                    if (
    xz < X [ 0 ][ 0 ])
                                                    
    X [ 0 ][ 0 ]= xz ;

                                                    if (
    xz > X [ 0 ][ 1 ])

                                                    
    X [ 0 ][ 1 ]= xz ;


                                                    if (
    yz < X [ 1 ][ 0 ])

                                                    
    X [ 1 ][ 0 ]= yz ;

                                                    if( 
    yz > X [ 1 ][ 1 ])

                                                    
    X [ 1 ][ 1 ]= yz ;






                                }

                }

    }






    bmpLine  ( X [ 0 ][ 0 ],  0 X [ 0 ][ 0 ],  phoehe  0 0 255 );
    bmpLine  ( X [ 0 ][ 1 ],  0 X [ 0 ][ 1 ],  phoehe  0 0 255 );
    bmpLine  ( 0 X [ 1 ][ 0 ], pbreite  , X [ 1 ][ 0 ],  0 0 255 );
    bmpLine  ( 0 X [ 1 ][ 1 ],  pbreite X [ 1 ][ 1 ],  0 0 255 );



    bmpShow ();


    Fl = Flaeche ( c X [ 0 ][ 1 ],  X [ 1 ][ 1 ],  k X [ 0 ][ 0 ],  X [ 1 ][ 0 ],& br ,& ho );
    printf ( "\n\n\nDie angenaeherte Flaeche des Reifenabdrucks betraegt:%.2lfmm^2\nDie zugehoerige Breite ist: %dmm \nUnd die Hoehe:%dmm\n\n\n\n\n" , Fl , br , ho );
    }
     
  2. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.