Отключить загрузку wxImage
Вопрос
У меня есть код , который работает здесь , за исключением того, что все неэнергетические 2 изображения перевернуты в направлении у. В файле wxImageLoader есть этот цикл, который я считаю виновником:
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
Но я не могу понять, как развернуть изображения.
Решение 2
Правильный цикл for:
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
Другие советы
В вашем цикле вы используете (rev_val - y)
для индекса пикселей вашего " старого " образ. Это заставит изображение перевернуться. Попробуйте найти альтернативу. Из вашего кода, который вы опубликовали, трудно понять, что такое функция rev_val.
Не связан с StackOverflow