2009-05-04 15 views
0

コードはhereで、2枚の画像のすべてのパワーがy方向に反転している点を除いては問題ありません。wxImageをアンインストールする

for(int y=0; y<newHeight; y++) 
    { 
     for(int x=0; x<newWidth; x++) 
     { 

      if(x<(*imageWidth) && y<(*imageHeight)){ 
       imageData[(x+y*newWidth)*bytesPerPixel+0]= 
       bitmapData[(x+(rev_val-y)*(*imageWidth))*old_bytesPerPixel + 0]; 

       imageData[(x+y*newWidth)*bytesPerPixel+1]= 
        bitmapData[(x+(rev_val-y)*(*imageWidth))*old_bytesPerPixel + 1]; 

       imageData[(x+y*newWidth)*bytesPerPixel+2]= 
        bitmapData[(x+(rev_val-y)*(*imageWidth))*old_bytesPerPixel + 2]; 

       if(bytesPerPixel==4) imageData[(x+y*newWidth)*bytesPerPixel+3]= 
        alphaData[ x+(rev_val-y)*(*imageWidth) ]; 

      } 
      else 
      { 

       imageData[(x+y*newWidth)*bytesPerPixel+0] = 0; 
       imageData[(x+y*newWidth)*bytesPerPixel+1] = 0; 
       imageData[(x+y*newWidth)*bytesPerPixel+2] = 0; 
       if(bytesPerPixel==4) imageData[(x+y*newWidth)*bytesPerPixel+3] = 0; 
      } 

     }//next 
    }//next 

しかし、私は画像を非反転する方法を見つけ出すことはできません。wxImageLoaderファイルでは、私が犯人であると信じて、このループがあります。

答えて

0

正しいです:

for(int y=0; y<newHeight; y++) 
    { 
     for(int x=0; x<newWidth; x++) 
     { 

      if(x<(*imageWidth) && y<(*imageHeight)){ 
       imageData[(x+y*newWidth)*bytesPerPixel+0]= 
       bitmapData[(x+y*(*imageWidth))*old_bytesPerPixel + 0]; 

       imageData[(x+y*newWidth)*bytesPerPixel+1]= 
        bitmapData[(x+y*(*imageWidth))*old_bytesPerPixel + 1]; 

       imageData[(x+y*newWidth)*bytesPerPixel+2]= 
        bitmapData[(x+y*(*imageWidth))*old_bytesPerPixel + 2]; 

       if(bytesPerPixel==4) imageData[(x+y*newWidth)*bytesPerPixel+3]= 
        alphaData[ x+y*(*imageWidth) ]; 

      } 
      else 
      { 

       imageData[(x+y*newWidth)*bytesPerPixel+0] = 0; 
       imageData[(x+y*newWidth)*bytesPerPixel+1] = 0; 
       imageData[(x+y*newWidth)*bytesPerPixel+2] = 0; 
       if(bytesPerPixel==4) imageData[(x+y*newWidth)*bytesPerPixel+3] = 0; 
      } 

     }//next 
    }//next 
+0

あなた自身の問題を解決しましたか?それとも、あなたが本来投稿するつもりだったのですか? – ParoXoN

+0

これはフリッピングの問題を解決しました – DShook

0

"古い"画像のピクセルのインデックスに(rev_val - y)を使用します。これにより、画像が反転します。代替案を探してみてください。投稿したコードから、rev_valの機能を知るのは難しいです。 forループ

+0

完全なコードは、私は質問OK – DShook

+0

に投稿されたリンクです。見逃した。コードは意図的に画像を反転させます。しかし、それは2つの画像のパワーに対しても同じように見える。 rev_val-yをyに置き換えてデバッグし、何が起こるかを見てください。 –

関連する問題