JPG rotieren



  • Ich habe eine Funktion geschrieben, mit der ich JPG rotieren kann.

    void __fastcall TCard::Rotate90(void)
    {
      TImage *Old = new TImage(Form1);
      Old->Stretch = true;
      Old->Width = CardImage->Width;
      Old->Height = CardImage->Height;
      Old->Picture->LoadFromFile(Path);
      CardImage->Width = Old->Height;
      CardImage->Height = Old->Width;
    
      for(int i = 0; i < Old->Width; i++)
      {
        for(int j = 0; j < Old->Height; j++)
        {
          CardImage->Canvas->Pixels[CardImage->Width - j - 1][i] = Old->Canvas->Pixels[i][j];
        }
      }
      delete Old;
    }
    

    Allerdings kommt die Fehlermeldung, dass ich nicht auf Pixel in einem JPG zugreifen kann.
    Gibt es noch eine alternative Lösung?
    Wie kann man JPG in Bitmap umwandeln?



  • TJPEGImage* jpg = new TJPEGImage;
    jpg->LoadFromFile(path);
    Graphics::TBitmap* bmp = new Graphics::TBitmap;
    bmp->Assign(jpg);
    delete jpg;
    

    Danach kannst du auf das Bitmap zugreifen und dein Bild auf dem Form erzeugen und diesem das Bitmap zuweisen, zum Beispiel.



  • Jo danke, damit gehts.


Anmelden zum Antworten