Google 网上论坛不再支持新的 Usenet 帖子或订阅项。历史内容仍可供查看。

Read data of an image file

已查看 170 次
跳至第一个未读帖子

ali_n...@yahoo.com

未读,
2021年11月20日 14:34:202021/11/20
收件人
I would like to read a PNG image file using Fortran and store the data
in an array. Does anyone know a library or bunch of code or a blueprint for how to do that?

Gary Scott

未读,
2021年11月20日 15:16:562021/11/20
收件人
On 11/20/2021 1:34 PM, ali_n...@yahoo.com wrote:
> I would like to read a PNG image file using Fortran and store the data
> in an array. Does anyone know a library or bunch of code or a blueprint for how to do that?
>

The easiest method I use is probably too expensive for you, but it is a
tailor made Fortran GUI/graphics API for windows (www.gino-graphics.com
just in case). Not super easy.

But here are some hints perhaps for windows:

https://stackoverflow.com/questions/4567875/how-would-i-load-a-png-image-using-win32-gdi-no-gdi-if-possible

Robin Vowels

未读,
2021年11月20日 22:41:402021/11/20
收件人
On Sunday, November 21, 2021 at 6:34:20 AM UTC+11, ali_n...@yahoo.com wrote:
> I would like to read a PNG image file using Fortran and store the data
> in an array. Does anyone know a library or bunch of code or a blueprint for how to do that?
.
There are examples of writing picture files in
"Introduction to Fortran 90/95, Algorithms, and Structured Programming".
The file is defined as direct access, unformatted, and with a record length of 1.
For reading in a picture file, the array would be defined as CHARACTER(1).

ali_n...@yahoo.com

未读,
2021年11月21日 03:23:402021/11/21
收件人
Thanks for your comment.

I saw "www.gino-graphics.com" before, it is not the kind of thing that I want.

ali_n...@yahoo.com

未读,
2021年11月21日 03:26:312021/11/21
收件人
Thanks for your comment.

I know how to read data. But converting an image (especially a PNG) to an array is different.
There is a structure for data. That structure makes reading difficult.

FortranFan

未读,
2021年11月21日 08:58:102021/11/21
收件人
On Saturday, November 20, 2021 at 2:34:20 PM UTC-5, ali_n...@yahoo.com wrote:
> I would like to read a PNG image file using Fortran and store the data
> in an array. Does anyone know a library or bunch of code or a blueprint for how to do that?

@ali_n...@yahoo.com,

You may also want to inquire about this at the Fortran Discourse site:
https://fortran-lang.discourse.group/

And also look into the growing effort toward a Fortran standard library and see if there are any options in there of interest to you regarding this (I've not checked), or even considering adding one to it:
https://github.com/fortran-lang/stdlib

Robin Vowels

未读,
2021年11月21日 11:06:072021/11/21
收件人
.
The image data is read into an array, as I described.
Picture files usually have header information at the beginning of the file.
With the data in the array, you process the bytes in the header to determine
the file structure.
You will need a specification of the PNG fomat in order to do that.

David Duffy

未读,
2021年11月21日 19:09:112021/11/21
收件人
ali_n...@yahoo.com <ali_n...@yahoo.com> wrote:
> I would like to read a PNG image file using Fortran and store the data
> in an array. Does anyone know a library or bunch of code or a blueprint for how to do that?

Need to use C-interop to call libpng, or use another program to convert
to ascii based format like Portable Bit Map using netpbm.

A quick search also found me
https://github.com/sage-git/forcv
0 个新帖子