سؤال
ولدي رمز هنا تعمل بشكل جيد إلا أن كل وعدم القدرة من 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(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