|
|
i have download an octree algorithm used to reduce the number of colors, but after got the new color palette by the octree alorithm, how can i transfer the 24bits R,G,B value into 8bits palette index?
for example, the 24bits pixel value is : R=125,G=100,B=231, how to change the three value into one value of palette index?
thanks!
|
|
|
|
|
The general answer is there are 2 parts to this sort of thing
1) Turn your 24 bit value into an 8 bit value
2) Look up the nearest colour in the pallette to the generated 8 bit value and use that index.
Part 1 is just math and your choice as to how you scale, bit shift and || together the values to form an 8 bit number.
Part 2 is harder in principle because you need to index your pallette. With only an 8-bit pallette though a straight nearest match linear search is probably fine.
I'm sure you can write reasonably efficient code to do these two steps.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
You should be able to
1) Use the octree algorithm to create an optimal palette based on the image pixel values
2) Use the resulting palette and the GetNearestPaletteIndex() API to convert each image
pixel to an index into the palette.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
thanks.
i have done the first step that creat an optimal palette, i will try the GetNearestPaletteIndex() API . further more i want to know the algorithm of converting rgb pixel to palette index based on the optimal palette. would you give me more help? thanks again.
|
|
|
|
|
Lao Wang wrote: i want to know the algorithm of converting rgb pixel to palette index based on the optimal palette
The GetNearestPaletteIndex() API does that but I'm not sure what algorithm it uses.
I don't have algorithms to share but a quick Google search gives some ideas like:
3-D Lookup Table Color Matching[^]
quick Color Averaging[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
I Have a property sheet with 8 big owner drawn button (I use GDI+ to draw the button in overrided DrawItem function).
The problem is (sometime) the property sheet become flickering so much (around 3 -4 second) after I rapidly switch between my application and
other application (Visual studio is the most noticable one).
anyone know what cause the problem ?
|
|
|
|
|
I had something like this. In my case, it was due to a line of code in OnDraw that was calling OnDraw another time (a SetVisible (...) into the OnDraw (...)). Take a look and watch out with update screen messages being called when they should and not going into a loop.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Hello guys,
I need to use the: The Pairing-Based Cryptography Library(http://crypto.stanford.edu/pbc/download.html), for one of my projects. And the problem is that I dont know how to integrate
it into my existing project; the web-site doesnt provide any manuals for this either.
I know how to integrate pure classes(.cpp, .h) files into my project, but not libraries. Does
anybody know any good tutorial for this ?
Thanks !
|
|
|
|
|
Project -> Add to project...
Change the extension to be able to find Libs, select it and ok.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
|
Which IDE are you using ? For VC2005, open the project properties -> "Linker" -> "Input" and in the field "Additional Dependencies" put the name of your library (with the full path).
You can also put the path in "Linker" -> "General" -> "Additional Library Directories".
|
|
|
|
|
Thanks Cedric, I am using VS2005, and I will try what you suggested later. Thanks !
|
|
|
|
|
Hello everyone,
I have searched and found the term automatic variable means function local variable, compared with static and global variable. Is that correct?
thanks in advance,
George
|
|
|
|
|
|
Hi gleat,
Sorry that I can not open the page, can you help to post some information here please?
regards,
George
|
|
|
|
|
Sure. Here it is:
<quote>
Automatic variables are variables local to a block. They are automatically allocated on the stack when that block of code is entered. When the block exits, the variables are automatically deallocated. Note that automatic variables are often called local variables.
The C storage class for automatic variables is auto; however auto is assumed unless otherwise specified. The basic syntax used to declare automatic variables in C is as follows
[storage_class] data_type variable_1, variable_2, ... variable_n;
An automatic variable will have an undefined value when declared, so it is good practice to initialize it with a valid value before using it.
</quote>
|
|
|
|
|
Great description, gleat!
regards,
George
|
|
|
|
|
George_George wrote: Sorry that I can not open the page
why that ? it's a link to the MSDN, and you often post on the MSDN forum, don't you ?!
bah, yet another lazy crappy poster
|
|
|
|
|
a variable can be declared auto matic, such as static or register .
auto matic is the implicit type when you declare a variable without specifying this statement.
for information, register will ask the compiler (but not force it to) place the variable into a processor register. this is for a variable that is often modified, to improve performances.
static has several meaning. here, we do not talk about the static on class members.
delcaring a variable static means that its value pertains wether the execution goes out of scope. out of the scope, the variable is not destroyed (thus keeping its last value for the next time the code is reexecuted), but not much accessible from outside.
auto matic simply means what we all know about variables lifetime. A variable is created at its declaration, is is release straight when going out of scope.
register double = 4.;
static char c = 'B';
auto int i1 = 3;
int i2 = -7;
|
|
|
|
|
Cool! I think your post is the most valuable which deserves rate 5.
have a good weekend,
George
|
|
|
|
|
|
It appears so, but he is still keeping his age a secret.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
What are the odds he's not as old as you or as ugly as me?
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|