Click here to Skip to main content
15,880,608 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hi Just a quick question, i've got this bit of code (below) and this is in my main form, it defines a glyph or symbol thats used in augmented reality, problem is that each symbol is different and say if i had 50 of these then the sourcecode would be quite big, and if i needed to add new symbols i would have to alter the code and re-compile all the time.

C#
Glyph_1 = new byte[7, 7] {{0,0,0,0,0,0,0},
    {0,0,1,1,1,1,0},
    {0,1,1,1,1,1,0},
    {0,1,1,1,1,1,0},
    {0,1,1,1,1,1,0},
    {0,1,1,1,1,1,0},
    {0,0,0,0,0,0,0}};


My question is can this be stored in SQL and how would i pull it?

Any help would be great, i've searched google and other places but no luck.

Cheers,
Pete
Posted
Updated 2-Sep-13 22:27pm
v2

1 solution

In this case I'd question the need to store these in a database: 7x7bytes x 50 glyphs = 2450 bytes ~ 2.5kB, which isn't very much. Also you only seem to have "1"s in your matrix, you could use booleans and convert, this would save space. Including a database on the target device will swamp any space saving you make, but again this depends on your setup. Saving the glyphs in the database will also impact performance in all cases, and if you are using on a remote device contacting a server, your device will need to be able to contact the server which may be a concern, depending on the nature of your app. Again, depending on your setup is, but it is normal to be able to include resources in your deployment, personally I'd deploy the image files.

As for as database solution, the short answer is yes. You need to find a data representation. Hear are a few solutions:


  • You can store image files in some databases, What you have looks like an input mask: the "1s" being switched on (and replaced with a colour on screen) . In this case you could use a B&W 1-bit bitmap. If you want colour you can store colour bitmaps
  • You can serialise the information serialize-multidimensional-arrays[^] and store as string. You could also condsider using a JSON serializer
  • Again if space(if storing locally) or bandwith(on a remote server) is a problem you can custom serialize. one option would be a CSV format with a row delimiter. One other solution, which works well if your solutions are all bits is to treat each row as a single binary number and use a csv, so your glyph would look like: 0, 30, 62,62,62,62,0
 
Share this answer
 
Comments
johannesnestler 3-Sep-13 10:17am    
very good and complete answer that goes beyond OPs "naive" question. well deserved 5ed

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900