|
Hey folks,
In the application that I'm writing, I have to resize an image then reduce the number of colours in it. I have got the resizing done OK - and have a few ideas for the colour reduction algorithm but the problem is they seem to be very inefficient. I was wandering if anyone had any good ideas as to quick algorithms - perfection is not necessary, I would say speed is more important, as long as the colours selected are visibly near.
I've read the article in MSJ (quite an old issue) about colour quantization but the problem is, this only provides a palette, where I need a new image to be produced with the new colours in the correct place etc, as the image will be stored in memory for further processing. Not asking much, eh? . BTW - don't worry Christian, I ain't planning GrausPaint XP (or anything like it for that matter, it's purely one part of a larger application).
cheers,
Andrew.
|
|
|
|
|
Try the Intel Image processing Library (IPL) or alternately the Image processing portion of the Intel Processing Primitives (IPP). I have used both and find them very efficient (they're optimized to exploit SIMD and SIMD2 on the P3/P4 respectively). They also have a ton of other canned functions you can use (rotate, zoom, filters of all kinds including the ability to use your own filter kernels, FFT's, DCT's, wavelets, etc. etc.).
The IPL interfaces very nicely to a windows DIB.
Give it a shot.
Al
--
|
|
|
|
|
Wavelets are available on the Intel Signal Processing Library (SPL) or the signal processing portion of the IPP, not on the Image processing libraries. The SPL is only suitable for single channel stuff (complex signals from comms. receivers and the like) instead of image data - 3 channel RGB data.
|
|
|
|
|
...there are lots of image processing libs around. i prefer ImgSource.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
*grin* Well, that's too bad. If TWO companies developed software with my name on it, my chances of fame would double....
There are a number of image libraries, we actually use the Intel one in GP, but it does not come with source and immediately means you're shipping another dll ( worse, you need to ship several if you want the fastest support for newer Intel processors ).
Paintlib is an option - www.paintlib.de - because they provide full source, so you can see how it's doing it and therefore learn from the code to roll your own. That sounds more useful to you, if you're not looking for the swag of features the Intel library provides.
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
If you already have the palette and want to do it by hands, did you try "Floyd-Steinberg" algorythm?
It should be quite simple, and with O(N) complexity.
You find the nearest color in the palette, then redistribute the error you've made to 3 close pixels. Well, I don't remember it exactly, but a search engine will do.
Paolo
|
|
|
|
|
What i need to do, is to change the Background Color of a Static TextControl.
My Application does not use the MFC, because of this I have to handle the WM_CTLCOLORSTATIC Message i think.
I have tried a lot of things with whis message now but nothing works like it should
I am some kind of newbie to this. and would be very glad if someone could give me a piece of code which changes the background color of all static controls on the form without using the mfc
I hope you can help me
best regards
Jakob W.
|
|
|
|
|
Did you try SetBkColor(hDC, color) ?
This should set the text's background and only that. Other parts not covered by text use the parent's background. Try handling WM_ERASEBKGND for the static control and setting a transparent text background, so you have only one place in which you specify the background color.
SetBkMode(hDC, TRANSPARENT) in your WM_CTLCOLORSTATIC to set transparent text.
have fun!
Paolo
|
|
|
|
|
hmm
I already tried this but it does not work...
I am using the following lines of code...
[code]
case WM_CTLCOLORSTATIC:
SetBkMode((HDC) wParam, TRANSPARENT);
break;
[/code]
But it does not change anything..
I hope you can help me with this.
Jakob W.
|
|
|
|
|
Are you returning a HBRUSH?
Try with ::GetStockObject(HOLLOW_BRUSH);
Paolo.
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
how do i get the lenght of the remote http file, before downloading it ?
[code]
define HTTPBUFLEN 512 // Size of HTTP Buffer...
char httpbuff[HTTPBUFLEN];
TCHAR szCause[255];
CString Cause;
CString contentlength;
Cause.Format("YES");
DWORD length;
CInternetSession mysession;
CStdioFile *remotefile = mysession.OpenURL(url,1,INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_RELOAD);
CFile myfile("C:\\test.txt", CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
int numbytes;
total=0;
do
{
ProcessMessages();
m_status.Format("%i",total);
UpdateData(FALSE);
numbytes = remotefile->Read(httpbuff, HTTPBUFLEN);
total+=numbytes;
myfile.Write(httpbuff, numbytes);
}while (numbytes);
[/code]
hope you can help me, thanks
|
|
|
|
|
ah yes by the way : GetLength() doesnt work..
|
|
|
|
|
Cast remotefile to a CHttpFile, and use
CHttpFile::QueryInfo(HTTP_QUERY_CONTENT_LENGTH ...)
|
|
|
|
|
I am having problems with giving a toolbar a custom background color. I understand that I have to handle the WM_NOTIFY message with the lParam being a NMTBCUSTOMDRAW pointer, but I can't figure out what to do next!!!! Please could someone show me how its done?
Thanks,
James Bird - birdjames@bigfoot.com
|
|
|
|
|
Hello
how can i add a progress bar to a column of a listCtrl?
(like in Napster)
thanks
|
|
|
|
|
First you need to be able to create a Progress Bar and List w/ CWnd::Create(EX) and not the Dialog editor. Make sure the Progress Bars is the child window of the List in CWnd::Create(EX). The List and Progress Bars created in the dialog editor or subclassing maybe harder to impossible to do. You may want to use array of Progress Bar objects because it maybe easier for moving the Progress Bars when the List is scroll(more on the later). Check MSDN for rect placement and sizeing functions in CListCtrl/CWnd. This placement is for CWnd::Create(EX) only in creating Progress Bars.
Next you find a way to get the to get new rect placement and sizeing after scroll and add/delete items. In CListCtrl placement and sizeing handlers you need to move the Progress Bars. I would add a item and subitem indexs to each object so you can pass then rect placement and sizeing functions in CListCtrl/CWnd then you move the Progress Bar window the window w/ CWnd::MoveWindow(). You will want to set the indexes before CWnd::Create(EX).
This is a general look at some hard stuff. I will try some code next if you need it and if I have time...
Real World Coding:
POP& BuyAPop(Money ADollar){...};
|
|
|
|
|
if u'll post some code, that will be great!
RG
|
|
|
|
|
Use owner-draw or custom-draw.
I wouldn't use child Progress controls. Better to draw the progress bar by yourself. Once you understand OwnerDraw or CustomDraw, that is very easy (just draw a filled rect).
There are some articles here and on CodeGuru, about those techniques. If you're lucky you only have to do some Cut&Paste.
Paolo.
|
|
|
|
|
Hi.
I designed a database as data source for an application I wrote. The
database has about 19 tables and several 1:n relations.
Esspecially one table, that has 2-3 relations, like [Patienten].[Kasse] =
[Kassen].[ID].
Now I'd like to query this table and instead of all the reference longs
should stay the [name] field of the related record.
I know how to do it for one field with an inner join like
'SELECT Name, Vorname, Kassen.Name FROM Patienten INNER JOIN Kassen ON
Patienten.Kasse = Kassen.ID'
But how can I do it for more fields? I can't cascade INNER JOIN, or is it
possible?
Thankfull for any answer...
--------------------------------------------------
"Pseudocode is code to demonstrate a concept, not designed to be run.
Like certain Microsoft software. "
|
|
|
|
|
Don't mind, I found out that cascading inner joins is possible.
--------------------------------------------------
"Pseudocode is code to demonstrate a concept, not designed to be run.
Like certain Microsoft software. "
|
|
|
|
|
|
SetFileAttributes(lpFileName, FILE_ATTRIBUTE_HIDDEN);
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
I have a custom windows message, that I need to map for my MFC project. However, I have NO clue on how to map a custom message, since it obviously doesn't appear in the "standard" list of messages.
Can anyone help?
|
|
|
|
|
If your message ID is a constant, use ON_MESSAGE. If you get the ID by calling RegisterWindowMessage(), then use ON_REGISTERED_MESSAGE.
--Mike--
http://home.inreach.com/mdunn/
"Make sure that if you are using a blow torch that you don't set anything on fire."
-- Chris Maunder
|
|
|
|
|
Hello all,
Could you please help me with this situation?
In the middle of my program, I create a FULL SCREEN TRANSPARENT HIDDEN WINDOW which is TOPMOST. When I click on my left mouse button, I want to retrieve the handle to the window under cursor(next z-order) underneath this transparent hidden window.
I am doing it like this when handling WM_MOUSEMOVE message, it is causing too much flickering.
// A full screen transparent window shows up
// Temporarily ShowWindow(hwnd, SW_HIDE) the full screen transparent window
// GetCursorPos() and do a WindowFromPoint() to get the window under cursor
// ShowWindow(hwnd, SW_SHOW) full screen transparent window
Could you show me how to use WindowFromPoint(), ChildWindowFromPoint(), and ChildWindowFromPointEx() to achieve this without hiding and showing the full-screen transparent window? Or is there any other way to do this? Thank you very much in advance.
|
|
|
|