Author Topic: Download Images from Web and use them  (Read 1372 times)

Gamingmayr

  • Guest
Download Images from Web and use them
« on: July 29, 2012, 07:00:34 am »
To reduce my App-size I thougt at the following: Is ist possible (or how ist it possible) to get Images from the Web and use them (for example download the @2x Images after the App installation)?

tim

  • Administrator
  • Hero Member
  • *****
  • Posts: 1595
  • Karma: +11/-1
    • View Profile
    • DragonFireSDK
Re: Download Images from Web and use them
« Reply #1 on: July 30, 2012, 07:50:37 am »
If you need to support Retina displays, you'll need to ship those assets with your app.  iOS will not look for @2x images in the Documents folder automatically.

However, if you want to download an image from the web and display it in your app, you can do so like this:

Code: [Select]
#include "DragonFireSDK.h"

int ViewHandle;
int ImageHandle;

int OnResponse(int event, char *response, int length)
{
int fh;
fh=FileCreate("logo.png");
FileWrite(fh,response,length);
FileClose(fh);
// Load the new image into our image object:
ImageSetImage(ImageHandle,"Documents/logo.png");
return(0);
}

void AppMain()
{
NetSend("http://www.google.com/images/srpr/logo3w.png",OnResponse);
ImageHandle=ImageAdd("MyImage.png");
ViewHandle=ViewAdd(ImageHandle,0,0);
}

void AppExit()
{

}

void OnTimer()
{

}
Tim Sommers
DragonFireSDK Team