Click here to Skip to main content
16,007,760 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: using _ecvt or f_fcvt??? Pin
Gérald Mercet22-Oct-01 6:00
Gérald Mercet22-Oct-01 6:00 
GeneralFind File including Subdirectories.. Pin
Bernhard22-Oct-01 4:07
Bernhard22-Oct-01 4:07 
GeneralRe: Find File including Subdirectories.. Pin
Carlos Antollini22-Oct-01 4:17
Carlos Antollini22-Oct-01 4:17 
GeneralRe: Find File including Subdirectories.. Pin
Ray Kinsella22-Oct-01 4:17
Ray Kinsella22-Oct-01 4:17 
GeneralTHANKS Pin
Bernhard22-Oct-01 4:53
Bernhard22-Oct-01 4:53 
GeneralCListCtrl different text colors for one item Pin
stephan22-Oct-01 3:40
stephan22-Oct-01 3:40 
GeneralRe: CListCtrl different text colors for one item Pin
Michael Dunn22-Oct-01 4:51
sitebuilderMichael Dunn22-Oct-01 4:51 
GeneralRGB data Pin
22-Oct-01 3:40
suss22-Oct-01 3:40 
Please, show me mistakes.
This code save array of pixels into txt file as RGB (0...255) for every pixel.
Code perfect works for 24 and 32 bitmaps, but it doesn't work for 8 & 16 bitmaps.

No, it works for 8,16, but save wrong array of pixel
What's the problem, i cann't find
If you know, please, help me

void CMainWnd::SaveAsArray(LPCTSTR filename)
{
int BytesPerPixel = (lpBitmap->biSizeImage)
/(lpBitmap->biHeight * lpBitmap->biWidth);

int WidthBytes = lpBitmap->biWidth * BytesPerPixel;

int size = sizeof(BITMAPINFOHEADER)
+ sizeof(RGBQUAD) * lpBitmap->biClrUsed;

BYTE *Bits = (LPBYTE)lpBitmap
+ size;

BYTE * ScanLine;
BYTE * Data;
BYTE Red, Green, Blue;

CStdioFile skadr;
CString string;
skadr.Open(filename, CFile::modeCreate|CFile::modeWrite);


for( int y = lpBitmap->biHeight; y>0; --y )
{

ScanLine = Bits + (WidthBytes * (y - 1));
Data = ScanLine;

for( int x = 0; x<lpbitmap->biWidth - 1; ++x )
{
LPRGBQUAD Quad = (LPRGBQUAD) Data;

Blue = Quad->rgbBlue;
Green = Quad->rgbGreen;
Red = Quad->rgbRed;

BYTE color = (Red
+ Green
+ Blue)/3;

string.Format("\t %d", color);
skadr.WriteString(string);

Data += BytesPerPixel;
}

string.Format("\n" );
skadr.WriteString(string);

}

skadr.Close();

}
GeneralRe: RGB data Pin
Christian Graus22-Oct-01 11:02
protectorChristian Graus22-Oct-01 11:02 
GeneralRe: RGB data Pin
22-Oct-01 11:22
suss22-Oct-01 11:22 
GeneralRe: RGB data Pin
23-Oct-01 5:43
suss23-Oct-01 5:43 
GeneralModeless Dialogs and Minimize Pin
Ray Kinsella22-Oct-01 1:42
Ray Kinsella22-Oct-01 1:42 
GeneralRe: Modeless Dialogs and Minimize Pin
Ray Kinsella22-Oct-01 5:23
Ray Kinsella22-Oct-01 5:23 
GeneralDrawing Graphs Pin
^GeeK^22-Oct-01 1:40
^GeeK^22-Oct-01 1:40 
GeneralRe: Drawing Graphs Pin
Christian Graus22-Oct-01 11:06
protectorChristian Graus22-Oct-01 11:06 
GeneralMiniDump (as part of DBGHELP.DLL) Pin
EiSl22-Oct-01 1:20
EiSl22-Oct-01 1:20 
GeneralWhich files of the ATL DLL project I need to provide Pin
mimi22-Oct-01 0:07
mimi22-Oct-01 0:07 
GeneralRe: Which files of the ATL DLL project I need to provide Pin
Michael P Butler22-Oct-01 0:41
Michael P Butler22-Oct-01 0:41 
GeneralManny thanks, Michael ! Pin
mimi22-Oct-01 0:59
mimi22-Oct-01 0:59 
GeneralSimple STL Stream Problem Pin
Derek Lakin21-Oct-01 23:35
Derek Lakin21-Oct-01 23:35 
GeneralRe: Simple STL Stream Problem Pin
markkuk22-Oct-01 0:27
markkuk22-Oct-01 0:27 
GeneralRe: Simple STL Stream Problem Pin
Derek Lakin22-Oct-01 0:43
Derek Lakin22-Oct-01 0:43 
GeneralMore Help Needed Pls :( Pin
Derek Lakin22-Oct-01 1:19
Derek Lakin22-Oct-01 1:19 
GeneralRe: More Help Needed Pls :( Pin
markkuk22-Oct-01 20:14
markkuk22-Oct-01 20:14 
GeneralRe: More Help Needed Pls :( Pin
Derek Lakin23-Oct-01 0:26
Derek Lakin23-Oct-01 0:26 

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.