Microchip
直播中

张早

7年用户 201经验值
私信 关注
[问答]

如何在C代码中转换图形图像(* .bmp,* .jpg等)(而不是通过工具)

我见过类似的帖子,但从来没有一个图形转换器实际位置的答案。我使用USB连接到我的董事会(拇指/闪存),其中包含一个图像文件。我想/需要采取这个图像文件,并更新我的董事会,使它使用这个图像文件作为溅射SCRE。因此,我在Flash中存储它。我不需要USB帮助——我可以自动检测设备,我可以读取文件。我不需要帮助编程内部闪存(我要么使用闪存驱动器,要么使用NVM模块和谐)。我需要帮助的是如何采取一个标准窗口*.bmp,*.jpg等文件,并将其转换为Microchip/HORLL(源代码)期望的格式。当你将图像导入到图形作曲器中时,它会经历一些转换过程,并在StasyCyFig Debug FrasegfxGFxAsAsET.cS类型中生成一个结构。这始终是GFXUIGIMASSETSET,并且该结构的一部分是指向图像数据的指针。数据部分与原始图像文件完全不同,并且大小也不同(字节)。图形作曲家使用的转换器代码可以用于我们的源代码中吗?(如果是这样,我会在哪里找到它?)或者,将图像文件转换成这些GFXIIVIEWASESET结构的转换过程是什么?谢谢,凯文

以上来自于百度翻译


      以下为原文

    I have seen similar posts about this, but never an answer of where a Graphics converter actually is located.

I am using a USB connection to my board (thumb/flashdrive) that contains an image file.
I want/need to take this image file and update my board so that it uses this image file as a Splash screen - thus store it in Flash.

I don't need help with USB - I have that working - I can auto detect the device, and I can read the file.
I don't need help with programming internal Flash (I'll either use the flash driver, or maybe use the NVM module in HARMony).

What I do need help with is how to take a standard Windows *.bmp, *.jpg, etc. file and convert it into the format that Microchip/Harmony (source code) expects.
When you import an image into the Graphics Composer - it goes through some conversion process and generates a structure in system_configdefaultframeworkgfxgfx_assets.c
The type of this is always  GFXU_ImageAsset  - and one piece of this structure is a pointer to the data of the image.  
The data section is definitely different than the original image file - and is a different size (in bytes) as well.

Is the Converter code that the Graphics Composer uses available for us to use in our source code? (if so where would I find it?)
or...
What is the conversion process for converting image files into these GFXU_ImageAsset structures?

Thanks,
Kevin

回帖(19)

张娜

2018-9-3 16:38:46
我能够阅读BMP(易)和JPG(复杂但可行的通过图书馆)…但是我不太确定你想要的输出格式:我过去看了一下它…如果你知道它是怎样的,那么一旦你在内存中有了解码后的位图,你就可以很容易地将它写入其他格式(特别是“容易”)。

以上来自于百度翻译


      以下为原文

    I am able to read BMP (easy) and JPG (complicated but doable via libraries)... but am not so sure about the output format you're asking for: I took some quick look at it in the past... no more.
 
If you know "how" it is, then - once you have the decoded bitmap in memory, you can easily write it into other formats (especially "easy" such as those).
举报

王淑英

2018-9-3 16:51:05
不确定如何做到这一点,但我用MLA编码了类似的函数。在MLA中,有低级别的调用将单个像素放在屏幕上;设置颜色以设置像素的颜色,并将像素添加到像素和指定的X和Y位置。我假设和声有相似的功能。最容易处理的图形格式是BMP。文件格式很简单,由三个部分组成,即头部的PaleTIT位图。头部给出了像X和Y的图像尺寸和其他两个部分的起始地址的信息。调色板部分是一个颜色列表,调色板中的每个颜色的索引由位图部分引用。例如,假设调色板中的索引3是蓝色的,索引5是绿色的,位图部分中的序列3、3、5、3给出三个蓝色像素和一个绿色像素。代码非常简单。1)从头部2得到高度和宽度。从头部3得到调色板的起始地址。他为位图中的每一个像素从位图4的循环开始位图的地址。5)获得位图条目(调色板索引)6)查找调色板表7中的颜色)将像素放在屏幕上,最好使用256色位图,这意味着调色板有256个条目和8位索引,因此位图中的每个条目是8位值。TTECHE/BMP/BMPFILFATAT.HTM对文件格式细节有很好的描述。

以上来自于百度翻译


      以下为原文

    Not sure how to do this in Harmony, but I coded a similar function using MLA.  In MLA there is are low level calls to put single pixels on the screen; SetColor to set the color of a pixel, and PutPixel to add a pixel and a specified x and y location).   I am assuming Harmony has similar functions.   
 
The easiest graphics format to deal with is BMP.  The file format is simple, consisting of three parts 
A header
A Palette
A Bitmap.
 
The header gives information like the x and y dimensions of the image, and the start addresses of the other two sections.   The palette section is a list of colors and the index of each color in the palette is referenced by the bitmap section.  For example, say that index 3 in the palette is blue , and index 5 is green, the sequence 3,3,5,3 in the bitmap section with give three blue pixels and one green pixel.  
 
The code is pretty simple
 
1) Get the height and width from  the header
2) Get the start address of the palette from the header
3) Get the start address of the bitmap from the header
4) Loop for each pixel in the bitmap.
      5) Get a bitmap entry (palette index)
      6) Look up the color in the palette table
      7) Put the pixel on the screen
 
Its best to stick with a 256 color bitmap, which means the palette has 256 entries and an 8 bit index, so each entry in the bitmap is an 8 bit value.
 
http://www.dragonwins.com/domains/getteched/bmp/bmpfileformat.htm  has a very good description of the file format details.
 
 
举报

陈杰

2018-9-3 17:10:48
也许和声使用塞格位图转换器工具。相关的SEGGER文档可能有助于输出格式。

以上来自于百度翻译


      以下为原文

    Maybe Harmony uses the Seger Bitmap Converter Tool.
The associated Segger documentation might help with the output format
   Attached Image(s)

举报

萧持毅

2018-9-3 17:26:38
我理解Windows *.bmp文件的格式,而且是的,我可以在屏幕上绘制单个像素(我不打算这样做)。(而不是试图粗鲁)-但是说你可以很容易地读BMP,但没有告诉我更多关于这并没有真正帮助我回答我的问题。我要求的代码,现有的微芯片和谐图形作曲家使用时,你添加一个新的“图像资产”到项目。这个工具已经TAKES在任何类型的图像中(*.bmp,*.jpg等),它创建了格式/Strut GFXIIGIMAEASETE格式的源代码。是否有人知道哪里有代码来执行这个相同的函数?谢谢,

以上来自于百度翻译


      以下为原文

    I understand the format of windows *.bmp files and such - and yes I could plot individual pixels on the screen (I'm not going to do that).  
And (not trying to be rude) - but saying you can easily read BMP, but not telling me much more about that doesn't really help me answer my question.
 
I'm asking for the code that the existing Microchip Harmony Graphics Composer uses when you add a new "Image Asset" to the project.
This tool already takes in any type of image (*.bmp, *.jpg, etc) and it creates the source code that is in the format of the type/struct  GFXU_ImageAsset.
 
Does anyone know where there is code to perform this same function?
 
Thanks,
举报

更多回帖

发帖
×
20
完善资料,
赚取积分