Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Loading as image a program generated file on Android

Author
Message
Mermaja
9
Years of Service
User Offline
Joined: 28th May 2015
Location: Vistabella del Maestrazgo, SPAIN
Posted: 16th Dec 2015 15:23
Hello.

I am writting a Tier1 program that creates a .png image file receiving it from a server, and then loads the created image to display it on a sprite. To receive the file I have used the basic multiplayer networking functions without problems. Everytihg works OK on Windows, but when testing on an Android device the image is not found as it is not located on the media folder, so it is not displayed.

Is there any way to have either the image written to the media folder - I have tried to use /media/image.png as the name when creating the image file, but it does not work- or the image loaded from the documents folder?

Thank you for your support.
Germán.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Dec 2015 15:39
How have you used the network commands?
In the past I have made a memblock from image, sent the data using standard network messages, and placed into a memblock at the client side. I then make image from memblock and save it where I choose.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Mermaja
9
Years of Service
User Offline
Joined: 28th May 2015
Location: Vistabella del Maestrazgo, SPAIN
Posted: 16th Dec 2015 15:59
Hello.

Thank you for your reply. I have sent the raw data read from the png image as blocks of integers. On the AppGameKit app I read the integers and write them to the file. It works OK, the only problem is that I cannot read the image as it is not located on the correct folder on Android. I have never used memblocks, and they may be a possible solution as I have no interest in saving the file but in displaying the image.

I will take a look.

Regards.
Mermaja
9
Years of Service
User Offline
Joined: 28th May 2015
Location: Vistabella del Maestrazgo, SPAIN
Posted: 16th Dec 2015 16:03
I should have commented that the server that sends the image is a normal C program, so I use common TCP sockets for the communication with the AppGameKit application.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 16th Dec 2015 16:41
Quote: "I read the integers and write them to the file."
If the data has been written to a file in the default file location in your Android App, then it should also be able to read that file. The file is placed in the App Data sandbox folder which gets checked first when loading media. Are you sure the Android version is actually receiving/writing the data (i.e. it's not a firewall issue is it?).


V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Mermaja
9
Years of Service
User Offline
Joined: 28th May 2015
Location: Vistabella del Maestrazgo, SPAIN
Posted: 16th Dec 2015 17:28
The data is received. The application displays a counter with the amount of data remaining and it goes down to 0, so the messages are arriving. In addition, when debugging I get the message that the file cannot be found, so I am sure it is a file location problem -the application will not proceed to display the image if the file hadn't been received and written. In the same local network, the app displays the image when running on windows. The same application writes and reads correctly a text file, so the problem is about the location of the image files.
Mermaja
9
Years of Service
User Offline
Joined: 28th May 2015
Location: Vistabella del Maestrazgo, SPAIN
Posted: 16th Dec 2015 17:40
I have verified that the image exists, using GetFileExists



The code above displays on screen "La imagen esta" but the image is not loaded as the debugger says

Failed to load image media/img.png (Note that Android paths are case sensitive) in main.agc at line 440

Regards
Mermaja
9
Years of Service
User Offline
Joined: 28th May 2015
Location: Vistabella del Maestrazgo, SPAIN
Posted: 17th Dec 2015 09:19 Edited at: 17th Dec 2015 09:20
@BatVink

Thank you very much for your comment about Memblocks. Now I read the PNG image on the PC, decode it and send it as a RGBA image. Te AppGameKit app receives it to a memblock and creates the image from it. Everything goes OK and it is less complicated.

Regards,
Germán.

Login to post a reply

Server time is: 2024-11-25 13:49:40
Your offset time is: 2024-11-25 13:49:40