how do you load files in windows phone 7? using XNA - windows-phone-7

I am porting an iphone game to windows phone 7. iphone works fairly similarly to Winmo7 in that you add all the files you want to be able to read to the project. we didn't want this extra step in our asset creation pipeline, so we just made it so all files were put into our own basic file archive, then just added that one archive file to the project. we then have an asset build process that exports all our assets, then creates this archive from them.
in winmo7 it caught me by surprise that you couldn't just do the same thing. as far as I know, the only way you can load data is though the content pipeline. we solved this fairly easily though by simply making a contentImporter that would just convert all the files to byte[] and export them as byte arrays, then you can simply load them an just directly access all the bytes that are in the file. unfortunately, unlike c++ where you would just cast memory to structures (because the file would already be stored in the structure's format) c# seems to require a more manual approach, where you use things such as BitConverter to load all the data into structures and classes from the byte array.
the thing is, we want to use our already existing asset export processes for things like textures and meshes, were we already have stuff setup for figuring out the exact pixel format that should be used for each texture ect. so in those cases we don't want to use the default Texture and Mesh content Importers. we tried making our on Texture ContentImporter, by simply making it return a Texture2D, but in order to create a Texture2D, you need a graphics device.
the second problem was the process of having to add every asset to the project. we decided that we didn't want to just load our dataArchive like we do for the iphone, because we DO want to use the default ContentImporters for Some of the data (like sound). but we solved this problem by making it so you just add one text file, with the root data dir in it, to the project, then made a ContentImporter that iterates through that directory structure and calls 'context.BuildAsset' on all the files there.
so summing up, we have one asset and ContentImporter that automatically handles the importing of all the assets in the data directory, thus solving the problem of having to add them manually to the project. some of these assets will be directed through the default ContentImporters (like sound and music, and xmls) while others will just be imported as byte[] and loaded manually, because we already have the asset in the format we want. in the case of those assets, it would be good if we could do the 'byte[] -> loaded manually' inside custom ContentImporters - offline- but for the first one we tried - Textures - it required a Graphics device to create the native Textue2D structure, and we couldn't find one in the ContentImporter framework.
so any thoughts? pointers? or is this the bestest way to do everything? I suppose another option would be to just convert all assets to a format the default Texture and Mesh processors can take in, and parameters to go with each of them (so we have a hand crafted 565 texture, convert it back to an 888 tga, then send it through the default texture pipeline with a parameter saying "convert this to 565")

TitleContainer
its this new class they added in 4.0, and is a little less explicit than the File stuff
just go TitleContainer.OpenStream(path)

It's straight forward to open a text file and read the contents in a WP7 project. Here is one way.
Uri linesUri = new Uri("lines.txt", UriKind.Relative);
StreamResourceInfo stream = App.GetResourceStream(linesUri);
StreamReader streamReader = new StreamReader(stream.Stream);
var contents = streamReader.ReadToEnd();
streamReader.Close();
I initially dragged the lines.txt file into my project from explorer - no other handling was necessary for this code to work.
Include the references you need...
using System.IO;
using System.Windows.Resources;

Rephrase the question and I would be more than happy to help you. Specifically, give examples of the issues you are trying to solve. I have done a lot work with the content pipeline in XNA and could share with you some tips.
I will update my answer once you give more details.

Related

hwpf, xwpf, hssf, and xslf poi picture extraction

I'm looking to extract all images from new and legacy Word documents and spreadsheets to assist in a real time document classification system, and looking at the documentation, I seem to have run into a problem. I'm having no problems finding documentation within the hwpf module and packages for extracting images from the file, but when it comes to the other 3, it seems as though they don't support the same methods.
What I want to do is to have one block of code that is document type agnostic when it comes to the 4 above mentioned types, I just want fast, easy access to the pictures in the files so I can move on to my next task, but at this point it looks like only the hwpf module supports extraction of pictures or the methods in 'PicturesTable'.
I'm also somewhat concerned about the performance of the library: it looks like it loads the entire file when all I want to do is scrape the images out of it. Any suggestions on a library that operates directly on the 'Data' bytestream and the folder structure of the .***x zip files?
I've already tried using OLEtools to try to extract pictures from the streams, and I'm now moving on to this tool. I havn't tried any tools that operate on the lower levels of the documents yet though.

How to convert PDF to Image without generating a file

Based on the Code How-To-Convert-PDF-to-Image-Using-Ghostscript-API
I trying to figure out how to get a image foreach page without creating the files
To get an image foreach Page i setted OutputToMultipleFile = true.
Then i went step for step through his code but i wasn't able to find the part where the files get created.
So i want to know what i need to change in this code?
or anything else which helps to achieve this
EDIT
here my current parameters:
args[0] =
args[1] =-dNOPAUSE
args[2] =-dBATCH
args[3] =-dSAFER
args[4] =-sDEVICE=pnggray
args[5] =-r130
args[6] =-sOutputFile="C:\Scannen1.PDF%d.png"
args[7] ="C:\Scannen1.PDF"
You need to use a device which doesn't write to file, all the image format devices write their output to file. You could use the display device which will return you a bitmap in memory as a template and write your own device, or you can modify one of the existing devices.
Modifying an existing device is a task for a developer and while not excessively difficult is not trivial either.
In any event, you aren't going to get what you want by fiddling with command line switches. Like Sinatr I'm puzzled by what you can usefully do with Ghostscript which doesn't involve writing to file.
Oh, one other possibility is to load the nulldevice, which is done in PostScript and is simply a bit bucket.

ExpressionEngine: File Manager

I’m new to EE and trying to learn the basics. Some questions about the File Manager:
I upload a photo and put “cat, kitten” in the description. When I do a search for “kitten”, it finds the photo. But when I do a search for “cat”, I get nothing. Any ideas what’s going on?
The file metadata are: file title, file name, description, credit, and location. What if I wanted to add custom fields? How do I do that?
In the template files, how do I access a particular manipulation (I call this “rendition”) of an image? Say I define a rendition “thumbnail” to be 100x100. How do I access that particular rendition in a template?
Is there a way to randomize the file names of the files being uploaded?
After uploading an image and testing it against PageSpeed, it turns out that the image can still be optimized via losslessly compressing it. How can this problem be addressed?
Ah, the file manager. Not EE's brightest spot.
It would not surprise me if the search in the File Manager was not
very robust. I'd try more variations to narrow it down (what kind of
characters affect the results - commas, dashes, spaces, etc ... do
partial terms match?)
You cannot currently add custom metadata to files in the file manager.
Use this syntax: {field_name:rendition}, e.g.,
{my_image:thumbnail} (docs).
Nope.
EE just uses the GD library available in your PHP install to resize
images. If you want the highest possible optimization, you'll have
to do your image manipulations yourself.
Given your queries, I would suggest you have a look at Assets by Pixel and Tonic. It offers a far superior file management experience on most of these fronts.

Saving files in xCode and making graph

I am new to programming. Now i have been learning for a few weeks and am now making my first app. Probably not for public, just for me. At least for now. So here it goes. I want the user to be able to enter his information (for example weight or something like that) into textField and then save it, so I can later form a graph (for example of weight loss through time). Now the graph should not be that much of a problem, since there are many tutorials on that. I am more interested in how to enter information, then save it so it can be later accessed. Any help? What should I read?
Thanks!
Working with UITextFields in Objective C is pretty straightforward - you can grab the NSString from such an object using the 'text' property. Use plists for storage locally, or JSON.
Look at core data tutorials especially related to Apples' doc on “Core Data and Cocoa Bindings”
CoreData shows how to setup objects and save them to a file or simple database. Cocoa Bindings are how to make input screens pass data to object models.
You should be able to write a program to enter weights, save them and show in a table without writing any code.

Loading files during run time in XNA 4.0

I made a content pipeline extension (using this tutorial) in XNA 4.0 game.
I altered some aspects, so it serves my need better, but the basic idea still applies. Now I want to go a step further and enable my game to be changed during run time. The file I am loading trough my content pipeline extension is very simple, it only contains decimal numbers, so I want to enable the user to change that file at will and reload it while the game is running (without recompiling as I had to do so far). This file is a very simplified version of level editor, meaning that it contains rows like:
1 1,5 1,78 -3,6
Here, the first number determines the object that will be drawn to the scene, and the other 3 numbers are coordinates where that object will be placed.
So, how can I change the file that contains these numbers so that the game loads it and redraws the scene accordingly?
Thanks
Considering you've created a custom content pipeline extension I presume you know how to load in data using streamreader? Where you could just empty your level data and load new data in by reading through the text file line by line?
The reason I mention this is because as far as I am aware it's not possible to load in data through the content pipeline during runtime especially because the xna redistribute does not contain the content pipeline.
Another option could be to change to using xml for the level file and use XElement which I quite recently found and this is my current method.
Here is a commented example of using StreamReader to load in simple level data from a .txt file. http://pastebin.com/fFXnziKv
In XNA 4, if you are using StorageContainer, you can do something like:
(...)
StorageContainer storageContainer = //get your container
Stream stream = storageContainer.OpenFile("Level.txt", FileMode.OpenOrCreate);
StreamReader sr = new StreamReader(stream);
while (!sr.EndOfStream)
{
String line = sr.ReadLine();
//use line to do something meaningful
}
stream.Close();
storageContainer.Dispose();
(...)
From personal experience, if you go for raw TextReader, the only problem is to get the path of your Content folder, which can be relatively easy to retrieve (in Windows only!)

Resources