可以把它放到SQL中吗? [英] Possible to put this into SQL?

查看:100
本文介绍了可以把它放到SQL中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是一个简单的问题,我有这段代码(下面),这是我的主要形式,它定义了增强现实中使用的字形或符号,问题是每个符号是不同的,并说是否我有50个,然后源代码会很大,如果我需要添加新的符号,我将不得不改变代码并重新编译。



 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 },
{< span class =code-digit> 0 , 1 1 1 1 1 0 },
{ 0 1 ,< span class =code-digit> 1 , 1 1 1 0 },
{ 0 1 1 1 ,< span class =code-digit> 1 , 1 0 },
{ 0 0 0 0 0 0 0 }};





我的问题是这可以存储在SQL中,我该如何拉它?



任何帮助都会很棒,我搜索谷歌和其他地方但没有运气。



干杯,

Pete

解决方案

在这种情况下,我会质疑是否需要将它们存储在数据库中:7x7bytes x 50 glyphs = 2450 bytes~2.5kB,这不是很多。你的矩阵中似乎只有1,你可以使用布尔值和转换,这样可以节省空间。在目标设备上包含数据库将淹没您所节省的任何空间,但这又取决于您的设置。在所有情况下保存数据库中的字形也会影响性能,如果您在联系服务器的远程设备上使用,则您的设备需要能够联系服务器,这可能是一个问题,具体取决于您的性质应用程序。同样,根据您的设置,但是能够在部署中包含资源是正常的,我个人会部署图像文件。



至于数据库解决方案,简短的回答是肯定的。您需要找到数据表示。听听是一些解决方案:





  • 您可以将图像文件存储在某些数据库中,看起来像什么输入掩码:打开1s(并用屏幕上的颜色替换)。在这种情况下,您可以使用B& W 1位位图。如果你想要颜色你可以存储颜色位图
  • 你可以序列化信息 serialize-multidimensional-arrays [ ^ ]并存储为字符串。您也可以使用JSON序列化程序进行考虑
  • 如果空间(如果存储在本地)或带宽(在远程服务器上)是一个问题,您可以自定义序列化。一个选项是带有行分隔符的CSV格式。另一个解决方案,如果您的解决方案都是位,则可以很好地将每行视为单个二进制数并使用csv,因此您的字形将如下所示:0,30,62,62,62,62,0

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.

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

解决方案

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


这篇关于可以把它放到SQL中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆