Edited from some code I found, but don't know why it works. Palette doesn't get used ever again after this code, but still gets applied to the image when compiled and ran?
Edited from some code I found, but don't know why it works. Palette doesn't get used ever again
What do you mean by "doesn't get used ever again"?
but still gets applied to the image when compiled and ran?
So you expect anyone to know what your entire program is doing, with the loops, functions, assignments, etc. that are being done, by posting only 2 lines of code?
Look, if you would think about the question, it means exactly what I am saying. It never gets used again; no where in the code is it used after that; ctrl-F, palette, nothing afterwards (3 entries) where it is declared and those two;
And if you don't know what 'applied' means?
well, no where in the code do you set bitmapInfo.bmiColors = palette, for example. WOW, you learned something today. Good Job!
There is nothing else that is related to the palette. So, I expect people to think, and not ask stupid questions when not even I understand. Unlike when I first started, I am pretty capable of finding out what codes to use and why it works or doesn't; your lucky I ask at all. It means that I am confident there is someone who actually thinks things through before asking questions, but no, Im always let down. The other code is irrelevant.
I have been looking over different examples of reading bitmapinfo and displaying the pic, and every example I find never actually used the palette; just read the palette in a for loop or similar to the code below. The palette on some may use it to printf() the rgb colors to the console, but nothing.
When I didnt use the code, already displayed, I got the myprog3.gif.
Then I added the code, already displayed, I got the myprog4.gif. Voila! It Works!
And this is besides the fact that most of the other code I looked at, once you comment out those lines of code that copy the palette from the image; when you run the program; it crashes OR doesn't display an image at all.
Go do some research and come back to me when your actually thinking.
The palette is useful only for screens displaying no more than 256 colors. They are quite rare nowadays. Usually, we have 32 bits per pixel, or more.
The BMP file format might contain a palette. But nowadays, images are rarely created with a palette anymore.
Edited from some code I found, but don't know why it works. Palette doesn't get used ever again after this code, but still gets applied to the image when compiled and ran?
So ... what exactly is bmp and what do you do with it afterwards? Do you write it to a .bmp file or maybe use it create a bitmap in memory? In which case, why would you not expect the pallette to be applied when you display the bitmap with the pallette in it?
Originally Posted by zaryk
Look, if you would think about the question, it means exactly what I am saying.
Originally Posted by zaryk
And if you don't know what 'applied' means?
Originally Posted by zaryk
So, I expect people to think, and not ask stupid questions when not even I understand.
Originally Posted by zaryk
your lucky I ask at all.
Originally Posted by zaryk
Im always let down.
Originally Posted by zaryk
Go do some research and come back to me when your actually thinking.
Wow ... just wow.
Grabs pop-corn and waits for Paul McKenzie to return.
Zacc:
This really isn't about my code, it's about every code I have looked at, including the one I provided, but if it makes you feel better, bmp is a struct. And its drawn to a window, just a plain gray window. bmp.bitmapinfo.bmColors isn't equal to anything, so unless your saying that it reads in automatically, then I might have a better understanding, but that doesn't explain when you add those lines that read in the palette, it makes the image correct.
the example image it provides, turns black when you comment out those lines
the example image displays correctly when you uncomment out those lines
Here have tux bitmap:
the tux image turns irregular when you comment out those lines
the tux image displays correctly when you uncomment out those lines
Edit: Maybe, its a compiler problem, so fyi I use codeblocks.
Last edited by zaryk; November 8th, 2010 at 02:54 PM.
Look, if you would think about the question, it means exactly what I am saying. It never gets used again; no where in the code is it used after that; ctrl-F, palette, nothing afterwards (3 entries) where it is declared and those two;
And if you don't know what 'applied' means?
well, no where in the code do you set bitmapInfo.bmiColors = palette, for example. WOW, you learned something today. Good Job!
There is nothing else that is related to the palette. So, I expect people to think, and not ask stupid questions when not even I understand. Unlike when I first started, I am pretty capable of finding out what codes to use and why it works or doesn't; your lucky I ask at all. It means that I am confident there is someone who actually thinks things through before asking questions, but no, Im always let down. The other code is irrelevant.
I have been looking over different examples of reading bitmapinfo and displaying the pic, and every example I find never actually used the palette; just read the palette in a for loop or similar to the code below. The palette on some may use it to printf() the rgb colors to the console, but nothing.
When I didnt use the code, already displayed, I got the myprog3.gif.
Then I added the code, already displayed, I got the myprog4.gif. Voila! It Works!
And this is besides the fact that most of the other code I looked at, once you comment out those lines of code that copy the palette from the image; when you run the program; it crashes OR doesn't display an image at all.
Go do some research and come back to me when your actually thinking.
Look, if you would think about the question, it means exactly what I am saying. It never gets used again; no where in the code is it used after that;
Programming is an exact science. Terms such as "never gets used" means nothing without a full explanation of what you are referring to. That could mean anything from a pointer to this palette not being referenced anymore, to some loop that gets only done once, to who knows whatever. We are not mind readers or psychic.
The point is this -- you need to learn to ask questions with more detail, so that others who have no idea what you mean can understand fully. Posting two lines of code and asking "what's happening?" is not the way to ask a serious question in any programming forum, not just CodeGuru. It is, if not amatuerish, unprofessional to formulate a question like that and then insult others (which is against forum rules to do so) who are asking you for more details. It is no different than someone posting this:
Code:
int i = 0;
i += 1;
and asking why their program only adds 1 to i only once and "never gets used", insults anyone asking for details, and then goes on about how their program has loops, while statements, function calls, ad nauseam.
As to my experience, try 30 years of programming, and currently in the business of imaging and graphics, so I could have helped you, but I guess not. So next time, formulate a question that explains in detail what is the problem you're having, and not expect us to use divining rods and a crystal ball to figure out what you're talking about.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; November 8th, 2010 at 09:20 PM.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.