Fehler beim drehen eines Bitmaps



  • Hallo zusammen,

    folgender Code:

    if (Image1->Picture->Graphic)
      {
       Graphics::TBitmap *tgtbmp = new Graphics::TBitmap();
       Graphics::TBitmap *srcbmp = new Graphics::TBitmap();
    
       srcbmp->Assign(Image1->Picture->Graphic);
       tgtbmp->Height = srcbmp->Width;
       tgtbmp->Width = srcbmp->Height;
       tgtbmp->PixelFormat = pf32bit;
       srcbmp->PixelFormat = tgtbmp->PixelFormat;
    
       int *tgtptr, *srcptr;
       for( int y = 0; y < tgtbmp->Height; y++)
       {
         tgtptr = (int*)tgtbmp->ScanLine[tgtbmp->Height-y];
         for(int x = 0; x < tgtbmp->Width; x++)
         {
           srcptr = (int*)srcbmp->ScanLine[x];
           tgtptr[x] = srcptr[y];
         }
       }
       Image1->Picture->Bitmap = tgtbmp;
       delete tgtbmp;
       delete srcbmp;
       if (!jpRotate)
       {
        jpRotate = new TJPEGImage();
       }
       jpRotate->Assign(Image1->Picture->Graphic);
       rotate = true;
      }
    

    manchmal klapt die Routine, ab und zu bekomme ich eine Zugriffsverletzung, vielleicht weis ja jemand wo der Fehler steckt. Danke



  • tgtptr = (int*)tgtbmp->ScanLine[tgtbmp->Height-y-1];
         for(int x = 0; x < tgtbmp->Width; x++)
         {
           srcptr = (int*)srcbmp->ScanLine[x];
           tgtptr[x] = srcptr[y];
         }
    

Anmelden zum Antworten