The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL2.0 Android problem with SDL_LoadBMP
sweetcare


Joined: 15 Feb 2015
Posts: 5
Hey everyone!

So I'd like to make a picture of mine the background of my app. It is just a gradiently colored picture, 1080*1920, you get the idea.
However, when I print it on the screen, it can't display every color, so it gets really bad quality. My phone is an LG G2, so it can display all kinds of colors...What is the problem here?

Code i'm using:

Code:
int main(int argc, char *argv[])
{
   int w,h;
   PICTURE picture;
   SDL_Window *window;
   SDL_Renderer *renderer;
   SDL_Surface *surface;


   SDL_CreateWindowAndRenderer(0, 0, 0, &window, &renderer);
   SDL_GetWindowSize(window,&w,&h);


   surface=SDL_LoadBMP("backg.bmp");
   picture.w=surface->w;
   picture.h=surface->h;
   picture.texture=SDL_CreateTextureFromSurface(renderer, surface);
   SDL_FreeSurface(surface);
   SDL_Rect destination={0,0,picture.w,picture.h};

   SDL_RenderClear(renderer);
   SDL_RenderCopy(renderer,picture.texture,NULL,&destination);
   SDL_RenderPresent(renderer);

   SDL_Delay(100000);

   return 0;
}


Also, would installing SDL_Image work? I tried it, but I couldn't get it working, if anybody got a guide, that would be great.

Thanks in advance!
theGiallo


Joined: 03 Nov 2014
Posts: 11
Location: Genova, IT
Have you tried with another image? What's exactly the problem? I've used SDL_LoadBMP successfully on Android, you can try if it works on your phone http://thegiallo.itch.io/space-master
theGiallo


Joined: 03 Nov 2014
Posts: 11
Location: Genova, IT
Oh, I'm using SDL 2.0.4-49174 from HG on Android.
SDL2.0 Android problem with SDL_LoadBMP
Eric Wing
Guest

On 2/16/15, sweetcare wrote:
Quote:
Hey everyone!

So I'd like to make a picture of mine the background of my app. It is just a
gradiently colored picture, 1080*1920, you get the idea.
However, when I print it on the screen, it can't display every color, so it
gets really bad quality. My phone is an LG G2, so it can display all kinds
of colors...What is the problem here?


I might be off, but this sounds like a pixel format quality issue.
Android used to prefer RGB 565 for RAM and performance. I don't know
what SDL's defaults are on Android (or iOS incidentally). I'm not sure
if/what SDL's mechanism is to control this, but my guess is to try
setting things to 888 with SDL_GL_SetAttribute.

https://wiki.libsdl.org/SDL_GL_SetAttribute

-Eric
--
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org