You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've attached a complete example that reproduces this bug (source code and a sample GTA2 TGA file), and a screenshot of how it looks in SDL_Image and how it should look like (libreoffice draw opened it correctly).
if(SDL_Init(SDL_INIT_VIDEO)<0)
exit(printf("SDL_ERROR: %s\n",SDL_GetError()));
win = SDL_CreateWindow("SDL_Image TGA Display",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
640, 480, SDL_WINDOW_SHOWN);
if(!win) exit(printf("SDL_ERROR: %s\n", SDL_GetError()));
// Load the image into a texture
renderer = SDL_CreateRenderer(win,-1,0);
img_surface = IMG_Load("1_Play.tga");
img_texture = SDL_CreateTextureFromSurface(renderer,
img_surface);
// Show it until the window gets closed
while(1)
{
SDL_Event event;
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, img_texture, NULL, &dest_rect);
SDL_RenderPresent(renderer);
SDL_WaitEvent(&event);
if(event.type == SDL_QUIT) break;
}
// Clean up
SDL_DestroyTexture(img_texture);
SDL_FreeSurface(img_surface);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(win);
SDL_Quit();
return 0;
}
On 2015-01-13 20:13:19 +0000, Philipp Wiesemann wrote:
Thank you for reporting this problem and providing an example.
It seems that the colors for this image are wrong because the bytes in img_surface->pixels are in the wrong order. There are two bytes for every pixel and if they are swapped it looks correct.
A similar problem was fixed in bug 1886. The changeset which introduced this bug [1] also changed the swapping for little endian platforms. It could be the cause.
I've added this workaround code to my project, because the target platforms are x86 and x86_64 only, but it would still be best if this was fixed upstream. Thanks!
On 2015-08-21 09:33:37 +0000, Amit Jain wrote:
Created attachment 2248
Swapping of bits happened for SDL_LIL_ENDIAN system which is wrong. It should be for SDL_BIG_ENDIAN system.
Hi Robotanarchy
Proper solution patch has been attached.
Hi Philipp Wiesemann
That fix given for bug 1886 is not exactly same as this bug. This issue was not fixed with that solution.
That bug was coming for selection of incorrect masking color for 24 bits per pixel image format. But here in this case, it is being selected correctly. But it was swapping for little endian system, that should be big endian instead.
This bug report was migrated from our old Bugzilla tracker.
These attachments are available in the static archive:
Reported in version: 2.0.0
Reported for operating system, platform: All, x86_64
Comments on the original bug report:
On 2015-01-10 00:11:11 +0000, robotanarchy wrote:
On 2015-01-13 20:13:19 +0000, Philipp Wiesemann wrote:
On 2015-01-19 21:26:13 +0000, robotanarchy wrote:
On 2015-02-03 19:57:05 +0000, robotanarchy wrote:
On 2015-08-21 09:33:37 +0000, Amit Jain wrote:
On 2017-09-11 07:17:39 +0000, Pankaj wrote:
On 2017-09-12 06:42:28 +0000, Sam Lantinga wrote:
The text was updated successfully, but these errors were encountered: