|
Seems like you should have something like:
CFile fileBitmap(...);
BITMAPFILEHEADER rBitmapFileHeader;
BITMAPINFOHEADER rBitmapInfoHeader;
fileBitmap.Read(&rBitmapFileHeader, sizeof(BITMAPFILEHEADER));
fileBitmap.Read(&rBitmapInfoHeader, sizeof(BITMAPINFOHEADER));
fileBitmap.Seek(rBitmapFileHeader.bfOffBits, CFile::begin);
unsigned char *m_pdata = new unsigned char[rBitmapInfoHeader.biWidth * rBitmapInfoHeader.biHeight];
fileBitmap.Read(m_pData, rBitmapInfoHeader.biWidth * rBitmapInfoHeader.biHeight);
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
You Mean there is now way to convert Long Pointer and declare array that point to that location in memory?
And i must read bitmap file .
there is somethings that when Bitmap compressed how can i read right Image data.
thanks for your attention.
best wishes.
|
|
|
|
|
mostafa_pasha wrote:
You Mean there is now way to convert Long Pointer and declare array that point to that location in memory?
And i must read bitmap file .
Yes, you must first read the data from disk into memory. At that point, you can "point" to them.
Without knowing more of what you are trying to do, I can't offer anything more helpful.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
i use OpenGL to draw 24-Bitmap Image to screen. in OpenGL image data is BGR not RGB!
so after read image data i must swap Red with Blue.
so i must access image data . i see that if my bitmap compressed and i try to read file
with iostream class and read image data , i can not convert it to raw data.
so i try use BITMAP.bmBits and copy image data to new array and then swap that.
Thanks a lot for your attention.
|
|
|
|
|
Bitmap image data is stored in (memory and file) BGR order.
INTP
|
|
|
|
|
If you wish to access the data directly, this is probably not the best method. If you apply a typecast to bmBits the error will go away but the code will still be wrong.
unsigned char* pData = (unsigned char*)bmBits;
....
if( bm.bmBits )
{
DWORD dwImageSize = bm.bmHeight * bmByteWidth;
unsigned char* pData = new unsigned char[dwImageSize];
if( pData )
{
memcpy(pData,bm.bmBits,dwImageSize);
.....
memcpy(bm.bmBits,pData,dwImageSize);
delete [] pData;
}
}
There are articles at CP on manipulating bitmaps directly as well at totorials. The book "Programming Windows" by Charles Petzold covers bitmaps and DIB Sections extensively.
Good Luck!
INTP
|
|
|
|
|
In addition to all of this, it's much easier to use a DIBSection wrapper, or use GDI+.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
thanks a lot John with best wishes for your answering..
about format of BITMAP i know if i wanna use in OpenGL i must swap R with B.
Is that right?
Christian thanks for your attention , but GDI+ is not for 3D.i use OpenGL for this
purpose so i can not use GDI+ when i Use dubbleBuffering in OpenGL.
Thanks a lot.
|
|
|
|
|
mostafa_pasha wrote:
i know if i wanna use in OpenGL i must swap R with B.
Only if OpenGL stores the bits in RGB. Windows always used BGR.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
|
HI everybody!
I need to know how to set the background color of a view.
I have tried using the 'SetBkColor(COLORREF color)' function but I can't get it to work.
I called the following line in the Draw function in class CView.
pDC->SetBkColor(COLORREF color);
And the background color remains white.
Can anybody tell me what to do?
_Lostris. . .
|
|
|
|
|
you need to "paint" it.
CDC::FillRect or something similir.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
FillRect has seemed to work just fine at first, but when I have to scroll the image, the part of the view that was not visible at the start is still white.
Do you have any other suggestions?
Thanx
_Lostris.
|
|
|
|
|
MSDN says:
"Sets the current background color to the specified color. If the background mode is OPAQUE, the system uses the background color to fill the gaps in styled lines, the gaps between hatched lines in brushes, and the background in character cells. The system also uses the background color when converting bitmaps between color and monochrome device contexts."
So, if you don't write or draw anything, you won't see the desired color.
My suggestion for the 'OnDraw(..)' function:
CRect rect;
GetClientRect(rect);
pDC->FillSolidRect(rect, RGB(255,0,0));
There might be other solutions.
|
|
|
|
|
In a Win32 application you can set the hbrBackground member of the window class structure
typically in "MyRegisterClass".
wcex.hbrBackground = CreateSolidBrush(RGB(255, 0, 0)); // This makes the window red
In MFC you can do something similar in PreCreateWindow.
Due Regards
Mahendra
|
|
|
|
|
How do you set the style for an edit control? I see that I can use the GetStyle function to retreive it's current style, but how do I change the style during run-time? I tried using SetStyle but apparently that isn't a valid approach.
- Aaron
|
|
|
|
|
Use SetWindowLong(hWnd, GWL_STYLE, ...) .
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thanks for response. Question: I'm trying to set the ES_PASSWORD style of an edit control..would this be the right way to go about it:
DWORD style = m_wndPassword.GetStyle ();
style |= ES_PASSWORD;
::SetWindowLong (m_wndPassword.GetSafeHwnd (), GWL_STYLE, style); When I run this the password style doesn't appear to be set at all. Any ideas? Thanks again.
- Aaron
|
|
|
|
|
Aaron,
If your using MFC then it's easier to use the ModifyStyle method:
m_wndPassword.ModifyStyle(0, 1, ES_PASSWORD);
Hope this helps,
Andy
|
|
|
|
|
Perhaps you meant this link?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thanks David
must have had a mad cut'n'paste moment.
Cheers,
Andy
|
|
|
|
|
Just tried that Andy, but it wouldn't work either. From the other replies it's looking like I'll need to recreate the control to do this. Thanks for the help though.
- Aaron
|
|
|
|
|
AFAIK some styles could not be changed at runtime: password/left/right/center.
You have to recreate control.
Igor Green
http://www.grigsoft.com/ - files and folders comparison tools
|
|
|
|
|
grigsoft wrote:
AFAIK some styles could not be changed at runtime...
ES_READONLY is another of those styles. But you can use EM_SETREADONLY instead!
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
monrobot13 wrote:
Any ideas?
Is the control single or multi-line?
It might not even be possible. Read here.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|