I'm having some issues getting a 16-bit (ARGB, 1-bit alpha, 5-bit colour channel) bitmap image which I converted using GRIT to display.
I have the following image, smpte_colour_bars.png. I converted it with GRIT using the following command line: grit smpte_colour_bars.png -gb -gB16 -fts -osmpte_colour_bars which gives me an *.s file for assembling into an object and a *.h header file for including in my project so I can reference the data.
However, when I use it in my project's code, all I get is a black screen: here.
I've looked through the relevant examples & documentation and I cannot track down the issue. Using DeSmuME's memory view, I can see that the data is being correctly written to memory & the tile view reflects that.
I have tested my code on two different emulators and real hardware and the problem is the same across all of them. Any insight into what might be going wrong would be much appreciated :)
It was a simple fix in the end after working out what was wrong. It turns out you must specify -gT! to explicitly disable transparency in the resulting bitmap otherwise the background is essentially see-through.
Related
I know few about this and i'm trying to keep building upon it. My goal is to do image stacking with some criteria using C language, as i came upon some cool ideas i think i should be capable of doing with my photos. My C background should be enough to understand what i may need. That being said...
So far i've learned how to read an existing .TIFF file and save it into a char array. The problem is i don't know in which way its data is contained so that i can then be able to analize individual pixels and modify them, or build another .TIFF file from data i previously read.
I've read some things about (a so called) libtiff.h which may be usefull but i can't find where to get it, neither how to install it.
Does anyone know how a .TIFF file data is stored so that i can read it and apply changes to it?
Also,
Does anyone have any experience with handling image files and editing in C? Where did you learn it from?
Do you know of any place i could search for information/tutorials?
Any help will be very usefull,
Thanks in advance.
You can do an enormous amount of very sophisticated processing on TIFFs, or any one of 190+ other formats with ImageMagick without any need to understand TIFF format or write any C. Try searching on Stack Overflow for [imagemagick]
If you want to do processing yourself, consider https://cimg.eu
Another option might be to convert your TIFFs to NetPBM which is much, much simpler to read and write in C. That would be as follows with ImageMagick:
magick INPUT.TIFF -compress none OUTPUT.PPM
My app tries to rotate images based on exif data.
I keep getting requests about jpegtran complaining about ’invalid SOS parameter for sequential jpeg” and jhead aborting operation. Apparently this is not even a fatal warning, and many forums give instructions on how to ignore it?
Invalid SOS parameters for sequential JPEG
Any ideas on how to get jpegtran to completely ignore this warning and process the images anyway?
I have an issue with sample images here
https://github.com/savolai/JPEG-Autorotate/issues/1
I thought already to first convert the image to non-progressive using jpegtran, but it complains even then and refuses to do it.
.\jpegtran.exe .\testimages\invalid-sos-parameters-progressive-jpeg\20180516_14530
8.jpg > .\testimages\invalid-sos-parameters-progressive-jpeg\nonprog.jpg
Does anyone know any other binaries or ways to get jpegtran.exe to ignore the error? Or do you know if mozjpeg jpegtran is more lax about this?
https://github.com/mozilla/mozjpeg/blob/master/BUILDING.md
I suspect that the source of the problem is that the spectral selection fields in the SOS marker are set to zero. These fields are meaningless in sequential JPEG but the standard says the values should be set to 0 and 63. Some JPEG references one sees on the internet say these values are ignored. Probably some encoders do not set them.
You might want to run a JPEG dumping program on your images to see if your spectral selection values are set to zero and 63. If they are not, you can write a relatively simple filter program that copies the JPEG stream while changing the spectral selection values.
I expect that the JPEGTRAN source code is online. If I am correct that it is making this needless check, you could build your own version with this commented out.
I have a general question about finished applications. When I go into the files of a windows computer application, some files make sense as to why they are there, such as the executable, various media files, .dll files, etc. However, what I don't understand is how there's potentially thousands of different files, located in hundreds of different directories (counting hierarchy) with anywhere between dozens and hundreds of different filetypes. Some of the filetypes don't even seem like actual files, the extension could be something completely obscure. How does the application know how to work with that? Are all of those files hand-written and compiled or are many of them supplied automatically upon generating a desktop application (which would vary based on the application, of course)? I've never actually compiled an application in any language, as I've been studying JavaScript as a starting point, and I recognize that JavaScript is not intended for creating standalone applications, it's used to implement inside HTML. This is why I have so many questions about the generation of the application itself.
To provide an example, a few of the file extensions I see contained in the Audacity application folder which I don't recognize are as follows: .lsp .raw .mo .ny .exp
Even that is a very short list compared to the amount of filetypes/extensions I usually encounter which I have no knowledge of. So, all in all, my main question is why there's such a crazy amount of files, folders, and filetypes/extensions being used by an application. Hopefully someone can help me understand.
Extra question, for those who might care to answer it:
What does it mean when you open a file in an application like Notepad++ (or a .plist editor) and it's just a bunch of unreadable characters? I'm assuming that means it's a compiled file, but I could use some clarification. This happens when I try to open an .exe, a .dll, etc. I understand why I can't edit things like that in a text editor of course, yet why all the strange symbols and characters? Why wouldn't it just throw an error upon trying to open it? Are all the strange characters just a way of attempting to interpret already compiled code?
Bear with me, I'm pretty new to programming and I'm trying to get a better understanding of the process behind actually generating a GUI-based desktop application. As I said before, my current knowledge doesn't extend to the point of actually compiling an application.
Thank you for any help, I really appreciate it.
Focusing on your extra question: you have to learn what a binary file and a text file is, but in short: Imagine you have a simple calculator program that stores the result in a file. Lets say the result you want to store is the number 64. You have to options to do it: saving it as text (characteres 6 and 4) or as a binary data.
If you store it as a text, you need two bytes: one for the code of the character 6 and other for the character 4. You can open that file with the notepad and you'll see that two characteres '64'.
If you store it as a binary value, you only need one byte, but if you open it with the notepad, you'll see the character whose code is 64: 'A'
Most of such "strange" files are resources needed by parts of the application. A complex application is constructed very modular, and each component may need to load different additional resources, often depending on conditions decided at runtime.
For example, on startup if a Qt-based application reads it should use German translation, it may load trans/de_DE.qm from a directory also containing other language files. Or a game may load level by level from different files depending on how far you've come.
Your second question is quite simple. Most resource files are read by an application function as stream of bytes. If e.g. such stream contains '005a' as 4 bytes, you'll see strange symbols in notepade.exe since that editor interprets such bytes as ASCII code, which means it prints the symbols it finds at place 0, 0, 5, and a in the ASCII table. But the application actually reads it in as 4 x 8 bits = 32bit value, which may mean a 32bit integer value of a variable in my simple example. So the variable value is set to 0x5a wich is decimal 90.
I'd like to display some sheet music in my WPF application which was generated by Lilypond. Lilypond can make postscript and PNG files - I've got the latter working, but I'd much prefer the former so that the music can be resized nicely. Is there a way to do that?
Simplest, but perhaps distasteful to many, would be to shell-out and use an external program render the postscript to png. You'd probably want to display some generic "working, please wait" message, as making an accurate progress-bar would be quite a chore.
Alternately, ghostscript can be used as a library and can read the PS from memory and render to memory, potentially saving some disk-access.
Does anybody know a good C sample that loads bitmaps and handles all the cases: rle, b/w bitmaps, so on?
Code should be cross-platform.
Thanks.
I would suggest using a library like SDL image
If you are looking for a minimal bmp loader this link will give you all you need to know about the BMP format, data structures and sample code without any library dependency to load:
http://paulbourke.net/dataformats/bmp/.
It also contains code to see the loaded BMP in a open gl texture, so pretty much all you need...
Chris Backhouse made a functional little BMP loader (with an eye to using them as OpenGL textures). It's C++, not C, and he admits it's not cross platform. However, it's small and easy to understand, so I thought I'd add the link here:
http://users.ox.ac.uk/~orie1330/bmploader.html
You need some external library to do this (I recommend ImageMagick). The ImageMagick web site also includes documentation and examples.
Check out for OpenCV Library developed by Intel .
If you are tied to the BMP file format, it's pretty simple to look at the header yourself and get the pixels. See this google search. One of the more interesting matches is here. The most counter-intuitive part is that every line of pixels is 4-byte aligned. Also, watch out for compressed BMPs... (My experience is that many third-party tools have trouble with compressed BMPs, so maybe some libraries you encounter will also..)
If you aren't tied to the BMP file format, I recommend libpng. The manual provides some sample code which is pretty clear.
As others suggested you might want to use an external library like SDL. If you want to learn something and do it yourself, see my answer to this very similar question: Getting RGB values for each pixel from a 24bpp Bitmap for conversion to GBA format in C where you'll find C code which prints out each pixel, and have a look at the wikipedia page about bmp files, because it's very good.