|
Hello,
i want to resize a loaded bitmap and i thought about to use
the windows method StretchBlt.
I can create a Bitmap out of a ByteArray and I can stretch it
according to the size of the window where it will be displayed
That's my way how i create a bitmap out of a bytearray.
you can see that i use StretchBlt.
CClientDC dc(pWnd);
CDC cdc;
CBitmap* pBitmap = NULL;
CBitmap* pOldBitmap = NULL;
cdc.CreateCompatibleDC(&dc);
dc.SetStretchBltMode(COLORONCOLOR);
::SetDIBits(NULL,hBitmap,0,dwHeight,pData,&Bitmapinfo,DIB_RGB_COLORS);
pBitmap = CBitmap::FromHandle(m_HBitmap);
pOldBitmap = cdc.SelectObject(pBitmap);
if(bStretchMode)
{
dc.StretchBlt(rect.TopLeft().x,rect.TopLeft().y,rect.Width(),rect.Height(),&cdc,0,0,m_iSrcWidth,m_iSrcHeight,SRCCOPY);
}
else
{
dc.BitBlt(rect.TopLeft().x,rect.TopLeft().y,rect.Width(),rect.Height(),&cdc,0,0,SRCCOPY);
}
cdc.SelectObject(pOldBitmap);
ReleaseDC(&cdc);
cdc.DeleteDC();
Now what I want is to load a bitmap from file, resize it and get a pointer
to the bytes of this resized bitmap. i dont need ti display the loaded
bitmap. the loaded bitmap is a binary bitmap,just black and white.
I load the image with this code
HBITMAP hBmp = (HBITMAP) ::LoadImage(NULL,
filename.GetBuffer(),
IMAGE_BITMAP,
0, 0,
LR_LOADFROMFILE |
LR_CREATEDIBSECTION);
BITMAP BM;
GetObject (hBmp,sizeof (BM),&BM);
CBitmap* pBmp = CBitmap::FromHandle(hBmp);
So, any suggestions ?
greetings,
cmos
|
|
|
|
|
cmos wrote: any suggestions ?
Yes.
Maybe
Create a second DIBsection, the size and bit-depth you want
Create a memory DC
Select the DIBSection into the new DC
StretchBlt the source bitmap to the memory DC, just like in your code above
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I need to read data between Starting of header and Ending of header
and have to write it on another file.
for EX Data between GS and GE at one para of file
and Data between ST and SE at one para of file.
~ is the end point of line .
Using MFC how i need to do this ?
The Txt file is below mentioned.
TUV *00* *00* *08*prov1 *14*BChome *020710*0600*U*00400*000000001*0*P*
GS*HS*prov1*BChome*20020710*0600*00001*T*004020~
ST*270*00001~
BHT*0022*13*10001*20020710*060000~
HL*1**20*1~
NM1*1P*2*PROVIDER1*****NI*111111111~
HL*2*1*21*1~
NM1*PR*2*BLUE CROSS HOME*****08*222222222~
HL*3*2*22~
NM1*IL*1*SMITH*JOHN*Q***MI*A33333333~
EQ*01~
SE*10*00001~
GE*1*00001~
TEA*1*000000001~
Thanks in advance,
Preethi
|
|
|
|
|
This looks like an EDI (835?) transaction.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
What exactly is your problem. What are you trying to parse.
Regards
Bram van Kampen
|
|
|
|
|
Hi,
I'm looking for a tutorial about Unit testing integrated in Visual studio.
I know that Visual Studio 2008 Team suite has the ability to write unit test(the problem is that
The unit test is written in managed C++ while my code is written in unmanaged c++).
Is there any tutorial?
How about another tools(for unmanaged code)?
With best regards,
Eli
|
|
|
|
|
|
|
I use
WideCharToMultiByte(CP_ACP,0,pBuf,len,pBuf_MBCS,n,NULL,NULL);
to convert.
\n sometimes is converted to 0D 0A , and sometimes to 0A .
Who knows what's the problem?
system
|
|
|
|
|
How do you know that? What is your input string and what about the output one?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
One string is very long, it compose a .txt file, about 50 lines, use \n as line break,
another is much shorter, less than 10 lines, also use \n as line break.
After converting, \n in the long one became \r\n , the other is sitll \n .
system
|
|
|
|
|
You may check, possibly with a hex editor (or the debugger), what are the actual linebreaks (i.e what are the UNICODE characters) of the two different strings.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
Nice to know.
It has been a while since I saw one of his posts at C++ forum.
BTW: THHB goes on without troubles!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
hi pallini,
BTW, THHB?
|
|
|
|
|
Rajkumar R wrote: BTW, THHB?
T hread H ijacking H appy B rigate, and you're live contributing to.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
And you should be ranked in top 10 on the THHB category right?
it seems there was a discussion on THHB on the board, can you link me to that.
|
|
|
|
|
Rajkumar R wrote: And you should be ranked in top 10 on the THHB category right?
Possibly.
Rajkumar R wrote:
it seems there was a discussion on THHB on the board, can you link me to that
Believe me, I don't know about.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi all,
How to generate beep sound or audio from a system not having speakers in VC++.Net?
I used Beep(freq,mili_secs) to generate a beep from motherboard.Will it work without sound card installed on system?
And how to know diffrent frequencies?
Regards,
Aniket A. Salunkhe
modified on Sunday, July 20, 2008 1:55 AM
|
|
|
|
|
Hi Aniket,
I think you should try using the MessageBeep[^] function.
Best regards,
Mihai Moga
|
|
|
|
|
Aniket Salunkhe wrote: I used Beep(freq,mili_secs) to generate a beep from motherboard.Will it work without sound card installed on system?
Yes, provided your system satisfy function requirements [^].
Aniket Salunkhe wrote: And how to know diffrent frequencies?
Documentation states that frequency maybe genrated in the "37 through 32,767" Hz range.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I have a problem with MDI forms. An MDI form in my application sets focus to a control on it(also scrolls to its location) when the form is clicked/activated/focused. I'm looking a way to prevent it. This is actually a C# application and I have no C++/WinApi knowledge. I tried Spy++ and checked messages it recieves when the mdi form is activated and when this problem occurs. I saw several messages like WM_FOCUS and such. I checked the message number, e.g 0022, and overriden WndProc function of the mdi form and tried to handle it like "if(m.Msg == 0022 || m.Msg == 22)return" for all of the messages includes word "focus" but this didn't do any good. I don't know what else I can do.
This is actually a .NET question I posted here but I thought maybe someone with C++/WinApi knowledge could help me with this. It's driving me insane and I appreciate any help.
|
|
|
|
|
Hi,
Preview works,
Capture does not work at
//
Problem: RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pBuild, NULL, pMux)
Please help.
void CWebCamDlg::OnStart()
{
// TODO: Add your command handler code here
UpdateData();
IGraphBuilder *pGraph2;
IMediaControl *pControl2;
IVideoWindow *pVidWin3;
ICaptureGraphBuilder2 *pBuild2;
hr =CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,IID_IGraphBuilder, (void**)&pGraph2);
pGraph2->QueryInterface(IID_IMediaControl, (void **)&pControl2);
///////////////////////////////////////////////////////////////////////////////////////////////
hr =CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC_SERVER,IID_ICaptureGraphBuilder2,(void**)&pBuild2);
pGraph2->QueryInterface(IID_IVideoWindow, (void **)&pVidWin3);
hr = pBuild2->SetFiltergraph(pGraph2);
//hr = pGraph2->AddFilter(pBase, L"Capture Filter");
IBaseFilter *pMux;
//CoCreateInstance(CLSID_AviDest, 0, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&pMux);
//pGraph2->AddFilter(pMux, L"AVI MUX");
IBaseFilter *pWriter;
CoCreateInstance(CLSID_FileWriter, 0, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&pWriter);
hr =pBuild2->SetOutputFileName(&MEDIASUBTYPE_Avi,L"c:\\dwk.avi",&pMux,0);
////////////////////////////////////////////////////////////////////////
//prolbem
//pBase from preview
hr = pBuild2->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pBase, NULL, pMux);
//////////////////////////////////////////////////////////////////////////
pControl2->Run();
pVidWin3->put_Owner((OAHWND)m_hWnd);
pVidWin3->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
CRect rc;
GetWindowRect(rc);
ScreenToClient(rc);
pVidWin3->SetWindowPosition(0, 0, rc.Width(), rc.Height());
// Release the mux filter.
pMux->Release();
IConfigAviMux *pConfigMux = NULL;
pMux->QueryInterface(IID_IConfigAviMux, (void**)&pConfigMux);
pConfigMux->SetMasterStream(1);
pConfigMux->Release();
IConfigInterleaving *pInterleave = NULL;
pMux->QueryInterface(IID_IConfigInterleaving, (void**)&pInterleave);
pInterleave->put_Mode(INTERLEAVE_CAPTURE);
pInterleave->Release();
}
Please Help!
Thanks
|
|
|
|
|
Hi,
I am using two differnt applications within one project in vc++.
For these I want to load two different application icons. However i dont want to another icon id. I want to use this same icon id. The reason is because i have all my menus,etc with this id. So i want to have this id but pointing to two differnt resource files, which would be decided in the compile time.
How to use/point a icon id to two different files programatically?
Priya Sundar
|
|
|
|
|
I don't understand the problem. Just make sure you assign the same values in the resource.h file.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|