Click here to Skip to main content
15,914,399 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: problem in the customization of title bar Pin
anuragguptartm9-Oct-07 0:51
anuragguptartm9-Oct-07 0:51 
GeneralRe: problem in the customization of title bar Pin
toxcct9-Oct-07 1:54
toxcct9-Oct-07 1:54 
Questionhow do i juzt implement only topsort algo here Pin
snoop828-Oct-07 23:27
snoop828-Oct-07 23:27 
AnswerRe: how do i juzt implement only topsort algo here Pin
chandu0048-Oct-07 23:34
chandu0048-Oct-07 23:34 
GeneralRe: how do i juzt implement only topsort algo here Pin
toxcct9-Oct-07 0:16
toxcct9-Oct-07 0:16 
AnswerRe: how do i juzt implement only topsort algo here Pin
chandu0048-Oct-07 23:46
chandu0048-Oct-07 23:46 
QuestionRe: how do i juzt implement only topsort algo here Pin
David Crow9-Oct-07 2:54
David Crow9-Oct-07 2:54 
Question[SOLVED]how to enable intellisense Pin
chandu0048-Oct-07 23:08
chandu0048-Oct-07 23:08 
AnswerRe: how to enable intellisense Pin
Waleed Eissa8-Oct-07 23:54
Waleed Eissa8-Oct-07 23:54 
GeneralRe: how to enable intellisense Pin
chandu0049-Oct-07 3:04
chandu0049-Oct-07 3:04 
QuestionHide Member from Intellisense list Pin
Waleed Eissa8-Oct-07 22:55
Waleed Eissa8-Oct-07 22:55 
QuestionRe: Hide Member from Intellisense list Pin
chandu0049-Oct-07 3:05
chandu0049-Oct-07 3:05 
AnswerRe: Hide Member from Intellisense list Pin
Waleed Eissa9-Oct-07 18:08
Waleed Eissa9-Oct-07 18:08 
GeneralRe: Hide Member from Intellisense list Pin
chandu0049-Oct-07 18:24
chandu0049-Oct-07 18:24 
QuestionClient server interaction Pin
William Engberts8-Oct-07 22:46
William Engberts8-Oct-07 22:46 
AnswerRe: Client server interaction Pin
jhwurmbach9-Oct-07 1:19
jhwurmbach9-Oct-07 1:19 
QuestionBitmap-Histogram using MFC Pin
go9398-Oct-07 22:45
go9398-Oct-07 22:45 
AnswerRe: Bitmap-Histogram using MFC Pin
Waldermort9-Oct-07 1:13
Waldermort9-Oct-07 1:13 
AnswerRe: Bitmap-Histogram using MFC Pin
jhwurmbach9-Oct-07 1:16
jhwurmbach9-Oct-07 1:16 
GeneralRe: Bitmap-Histogram using MFC Pin
Chris Losinger9-Oct-07 3:13
professionalChris Losinger9-Oct-07 3:13 
GeneralRe: Bitmap-Histogram using MFC Pin
jhwurmbach9-Oct-07 3:51
jhwurmbach9-Oct-07 3:51 
GeneralRe: Bitmap-Histogram using MFC [modified] Pin
Chris Losinger9-Oct-07 4:14
professionalChris Losinger9-Oct-07 4:14 
jhwurmbach wrote:
May or may not.


you're calling how many functions per pixel?

vs. my single macro (which is a couple of bit shifts and logical ORs) and an array index.

jhwurmbach wrote:
You are newing 28MB in one piece here


64MB. but that's really not a big deal. your map will potentially require many times more than that.

you're right that your map will require less memory (though more memory allocations) in cases where images have few colors.

jhwurmbach wrote:
AND you are still limited to 8-bit per color.


true. it's an easy enough problem to fix. and your map will potentially suffer the same memory bloat.


-- modified at 10:34 Tuesday 9th October, 2007

ok... i'm bored, so i did some testing:
typedef std::map< int, int> HistoMapT ;

const int w = 1000;
const int h = 1000;

BYTE *p = = new BYTE[w * h * 3];

// init to a gradient (also ran init'd to 0s)
for (int x=0;x< w;x++)
{
	for (int y=0;y< h;y++)
	{
		p[x * 3 + y * w * 3 + 0] = x % 256;
		p[x * 3 + y * w * 3 + 1] = y % 256;
		p[x * 3 + y * w * 3 + 2] = (x + y) % 256;
	}
}


{
	CTimer c("Map"); // TRACE's time elapsed from construction to destruction
	BYTE * pix = p;
	HistoMapT theMap;

	for (int x=0;x< w;x++)
	{
		for (int y=0;y< h;y++)
		{
			int color_number = RGB(pix[0], pix[1], pix[2]);
			HistoMapT::iterator theIterator = theMap.find(color_number);
			int value = 1;
				
			if (theIterator != theMap.end() ) 
			{
				value += (*theIterator).second;
			}
			theMap.insert(std::pair< int, int>(color_number, value));

			pix+=3;
		}
	}
}

{	
	CTimer c("C");
	BYTE * pix = p;
	int *histo = new int[256 * 256 * 256];
	memset(histo, 0, 256 * 256 * 256 * 4);
	for (int x=0;x< w;x++)
	{
		for (int y=0;y< h;y++)
		{
			histo[RGB(pix[0], pix[1], pix[2])]++;
			pix+=3;
		}
	}

	delete [] histo;
}

delete [] p;


here are the results:

// source image init'd to gradients
Map 2.01s
C 0.16s

// source image init'd to all zero
Map 0.30s
C 0.08s

// changing the source init to
p[x * 3 + y * w * 3 + 0] = x % 256;
p[x * 3 + y * w * 3 + 1] = y % 256;
p[x * 3 + y * w * 3 + 2] = x / 256;

Map 11.25s
C 0.08s

-- modified at 10:42 Tuesday 9th October, 2007


-- modified at 10:54 Tuesday 9th October, 2007



GeneralRe: Bitmap-Histogram using MFC Pin
jhwurmbach9-Oct-07 4:39
jhwurmbach9-Oct-07 4:39 
GeneralRe: Bitmap-Histogram using MFC [modified] Pin
Chris Losinger9-Oct-07 4:44
professionalChris Losinger9-Oct-07 4:44 
GeneralRe: Bitmap-Histogram using MFC Pin
jhwurmbach9-Oct-07 5:21
jhwurmbach9-Oct-07 5:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.