Click here to Skip to main content
15,894,291 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionLocking 24bpp bitmap portion Pin
Chesnokov Yuriy23-Jul-09 1:24
professionalChesnokov Yuriy23-Jul-09 1:24 
AnswerRe: Locking 24bpp bitmap portion Pin
uraeu23-Jul-09 3:08
uraeu23-Jul-09 3:08 
AnswerRe: Locking 24bpp bitmap portion Pin
Chesnokov Yuriy23-Jul-09 4:07
professionalChesnokov Yuriy23-Jul-09 4:07 
AnswerRe: Locking 24bpp bitmap portion Pin
Randor 23-Jul-09 5:25
professional Randor 23-Jul-09 5:25 
QuestionRe: Locking 24bpp bitmap portion Pin
Chesnokov Yuriy23-Jul-09 8:06
professionalChesnokov Yuriy23-Jul-09 8:06 
AnswerRe: Locking 24bpp bitmap portion Pin
Randor 23-Jul-09 8:27
professional Randor 23-Jul-09 8:27 
QuestionRe: Locking 24bpp bitmap portion Pin
Chesnokov Yuriy23-Jul-09 19:24
professionalChesnokov Yuriy23-Jul-09 19:24 
AnswerRe: Locking 24bpp bitmap portion Pin
Randor 23-Jul-09 23:25
professional Randor 23-Jul-09 23:25 
I am not understanding the numbers you are showing me. For example:

Chesnokov Yuriy wrote:
257 * 3 = 771, 771 / sizeof(DWORD) = 192.75


Why are you dividing 771 by sizeof(DWORD)? This does not make any sense to me. Each pixel is represented by 3 bytes or sizeof(RGBTRIPLE). The padding will be at the end of the memory allocated. Like this:

xxxxxxxxxxxxxxxxPADDING

You should be able to calculate the original bitmap width by checking that stride modulo RGBTRIPLE is equal to zero. For finding the best width where width is equal to stride you can multiply width by RGBTRIPLE and check that it is equal to the alignment. Something like this:

#define ALIGN(val)((val + 3) & ~3)
#define ISSTRIDEALIGNED(val)((val * sizeof(RGBTRIPLE)) == ALIGN(val * sizeof(RGBTRIPLE)))

DWORD OriginalWidth24(DWORD dwInStride)
{
	if(0 != dwInStride % sizeof(RGBTRIPLE))
	{
		--dwInStride;
	}
	return dwInStride / sizeof(RGBTRIPLE);
}

DWORD BestWidthEqualStride(DWORD dwWidth)
{
	while(dwWidth && (sizeof(RGBTRIPLE) * dwWidth) !=  ALIGN(dwWidth * sizeof(RGBTRIPLE)))
	{
		--dwWidth;
	}
	return dwWidth;
}


And you can check their values:

DWORD dwBitmapWidth = 257;
DWORD dwNonAlignedSize = (dwBitmapWidth * sizeof(RGBTRIPLE));
DWORD dwAlignedSize = ALIGN(dwBitmapWidth * sizeof(RGBTRIPLE));
DWORD dwOriginalWidth = OriginalWidth24(dwAlignedSize);
DWORD dwWidthEqualsStride = BestWidthEqualStride(dwBitmapWidth);


Best Wishes,
-David Delaune
Question"Ok" and "Apply" functions are overruled by the other property pages. Pin
aravind.sn23-Jul-09 1:14
aravind.sn23-Jul-09 1:14 
AnswerRe: "Ok" and "Apply" functions are overruled by the other property pages. Pin
uraeu23-Jul-09 3:03
uraeu23-Jul-09 3:03 
GeneralRe: "Ok" and "Apply" functions are overruled by the other property pages. Pin
aravind.sn23-Jul-09 3:14
aravind.sn23-Jul-09 3:14 
QuestionIn Windows Operating system where does the ACL of an object is stored Pin
Anil Veeraghattapu 423-Jul-09 0:52
Anil Veeraghattapu 423-Jul-09 0:52 
AnswerRe: In Windows Operating system where does the ACL of an object is stored [modified] Pin
Adam Roderick J23-Jul-09 1:08
Adam Roderick J23-Jul-09 1:08 
QuestionVisual C++ MFC,CDocument::SetTitle invalid Pin
akira3222-Jul-09 21:38
akira3222-Jul-09 21:38 
AnswerRe: Visual C++ MFC,CDocument::SetTitle invalid Pin
Kushagra Tiwari23-Jul-09 0:04
Kushagra Tiwari23-Jul-09 0:04 
QuestionProblem with ReadFile Funhction Pin
Shiv Murti Pal22-Jul-09 21:19
Shiv Murti Pal22-Jul-09 21:19 
AnswerRe: Problem with ReadFile Funhction Pin
Michael Schubert22-Jul-09 21:47
Michael Schubert22-Jul-09 21:47 
GeneralRe: Problem with ReadFile Funhction Pin
Shiv Murti Pal22-Jul-09 23:37
Shiv Murti Pal22-Jul-09 23:37 
GeneralRe: Problem with ReadFile Funhction Pin
Michael Schubert22-Jul-09 23:53
Michael Schubert22-Jul-09 23:53 
GeneralRe: Problem with ReadFile Funhction Pin
Shiv Murti Pal23-Jul-09 2:27
Shiv Murti Pal23-Jul-09 2:27 
GeneralRe: Problem with ReadFile Funhction Pin
krmed23-Jul-09 2:51
krmed23-Jul-09 2:51 
GeneralRe: Problem with ReadFile Funhction Pin
Shiv Murti Pal23-Jul-09 18:56
Shiv Murti Pal23-Jul-09 18:56 
GeneralRe: Problem with ReadFile Funhction Pin
Shiv Murti Pal24-Jul-09 1:25
Shiv Murti Pal24-Jul-09 1:25 
QuestionHow to generate Keyboard events ? Pin
Member 383463022-Jul-09 21:14
Member 383463022-Jul-09 21:14 
AnswerRe: How to generate Keyboard events ? Pin
Emilio Garavaglia22-Jul-09 21:52
Emilio Garavaglia22-Jul-09 21:52 

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.