|
CImage imageOriginal;
imageOriginal.Load(_T( "read.tif" ));
<code>CRect rectCopy(9177,68, 10566, 635);</code>
CImage imageNew;
imageNew.Create(rectCopy.Width(), rectCopy.Height(), imageOriginal.GetBPP());
imageOriginal.BitBlt(imageNew.GetDC(), rectCopy, rectCopy.TopLeft());
imageNew.Save(_T("D://imgnew.jpg"));
imageNew.ReleaseDC();
when i gave this rect portion ..the saving images contains ..full black
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
rajugis wrote: when i gave this rect portion ..the saving images contains ..full black
I think this problem could occur when your original image is indexed. You can read about indexed colors here[^].
If we want to copy indexed images we have to copy their color tables too. We can easily do this with CImage class.
First we have to check if the image is indexed and if it is than copy its color table, just like that:
if(imageOriginal.IsIndexed())
{
const int nMaxColors = imageOriginal.GetMaxColorTableEntries();
RGBQUAD* pColorTable = new RGBQUAD[nMaxColors];
imageOriginal.GetColorTable(0, nMaxColors, pColorTable);
imageNew.SetColorTable(0, nMaxColors, pColorTable);
delete [] pColorTable;
}
This code must be inserted after the creation of the new image. I've made a test application and it works fine for me for both indexed and on-indexed TIFFs. Here is the complete method:
void CTestCImageAppDlg::OnBnClickedButtonTest()
{
CImage imageOriginal;
HRESULT hrLoad = imageOriginal.Load(_T("D:\\testImg1.tif"));
if(FAILED(hrLoad))
{
CString msg;
msg.Format(_T("Error on load. Code:%08x"), hrLoad);
AfxMessageBox(msg);
return;
}
CRect rectCopy(0, 0, imageOriginal.GetWidth() / 2, imageOriginal.GetHeight() / 2);
CImage imageNew;
imageNew.Create(rectCopy.Width(), rectCopy.Height(), imageOriginal.GetBPP());
if(imageOriginal.IsIndexed())
{
const int nMaxColors = imageOriginal.GetMaxColorTableEntries();
RGBQUAD* pColorTable = new RGBQUAD[nMaxColors];
imageOriginal.GetColorTable(0, nMaxColors, pColorTable);
imageNew.SetColorTable(0, nMaxColors, pColorTable);
delete [] pColorTable;
}
CRect rect(rectCopy);
rect.OffsetRect(-rectCopy.left, -rectCopy.top);
imageOriginal.BitBlt(imageNew.GetDC(), rect, rectCopy.TopLeft());
imageNew.ReleaseDC();
HRESULT hrSave = imageNew.Save(_T("D:\\testImg2.tif"), Gdiplus::ImageFormatTIFF);
if(FAILED(hrSave))
{
CString msg;
msg.Format(_T("Error on save. Code:%08x"),hrSave);
AfxMessageBox(msg);
return;
}
}
I hope this helps you.
Regards
Nuri Ismail
modified on Thursday, September 17, 2009 4:12 AM
|
|
|
|
|
wow ..its great ...
thanks for your help ...............
really thanks Nuri !!!!!!11
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
You are welcome!
|
|
|
|
|
Could someone give me a hint on how I could show one view full screen on a second monitor while the app with all the navigation pane, toolbars, menus, etc. stays on the main monitor?
Ideally, this would just be a second view opened for the current document that can escape the apps frame and go over to the other monitor and make itself full screen.
I've considered just using a second app with sockets for communications between the two apps.
I've considered using a secondary GUI thread with a CWnd derived object that is sort of operating outside of MFC's doc/view architecture.
|
|
|
|
|
It's quite a good question! I think there's an article in it somewhere!
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Hi all,
I have build a MFC single document app, which is not show in full screen at run time. Now in which class will i change the code and what code (Frame, or in App) for show it full screen when i click at run button.
Thanks to all
Shaheen
|
|
|
|
|
Have you looked at the call to ShowWindow() in the app's InitInstance() method?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
|
Hi,
This is John, i am developing one application in VC++ using TAPI 3.0 sdk. I am developing this application for to get some call center features. In call centers they will have phones with some dedicated extensions. Agents will logging onto the phones. Now i want to get agent login and log out events from TSP.
Can any one help me how to retreive those evets from TSP.?
If any one provide me some sample TAPI 3.0 applications, that could be great..
Thanks in advance..
Thanks
John.
|
|
|
|
|
Hi,
Here is one more basic question from my side.
What are the files created when we compile a C++ program.
And what the .obj file contains exactly?How do we debug it?
Thanks in advance.
-----------------------------
I am a beginner
|
|
|
|
|
When you compile a .CPP or .C file an .OBJ file (object file) is produced. There are also .LIB files (library files) which can be regarded as a collection of .OBJ files. These files cannot be loaded or executed by the OS. When you link the input is .OBJ and .LIB files and the output is an executable (generally a file with the .EXE or .DLL extensions). These files can be loaded and executed by the OS. What I'm describing is how things work in Windows, but the same principles hold for other systems.
Steve
|
|
|
|
|
thanks you for your answer...
But what is the content of this .Obj fle?....how we compile them?
-----------------------------
I am a beginner
|
|
|
|
|
hrishiS wrote: how we compile them?
You don't. They are the result of the compilation. The linker uses one or more of them to create the final EXE or DLL.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Imaging the following program (in a imaginairy programming language):
Local int x,y
x=5
y=sin(x)
Now assume the function Sin() is not specified in this program, but in a library. When the program is compiled the compiler knows how to compile the first 2 statements (it can replace these statements to machine code that does functionally the same). This is written to the OBJ-file. The compiler can not compile the last line because this is an external defined function. So the compiler writes in the obj-file the machine code to jump to an unknown adress. In the next pass the linker will fill this unknown adress to the adress of the function Sin().
As said before: the compiler creates for each C-file a equivalent obj-file. The linker merges these and other obj's and/or lib's to an exe. Essentially an obj-file is an exe-file that have jumps to external defined functions not filled in. This is the reason you can't run obj-files (it will crash as soon as it wants to call the external function). An obj-file is an intermediate file in the compile/link process.
Aside: The above is over simplified, in reality it is more complex as described: actually tables of unknown adresses are writen to the obj-file so the linker knows which adresses it must fill in.
Rozis
|
|
|
|
|
Hi to all,
Could anyone please give me a hint, why we say, C follows top down and C++ bottom up approach.
Thanks
-----------------------------
I am a beginner
|
|
|
|
|
See here[^].
BTW: For this kind of questions you should first ask "uncle Google".
Regards
Nuri Ismail
|
|
|
|
|
Hi all,
i m using system tray icon for my application ,but when i run my application on windows xp the ballon of system tray icon not displayed,while its working fine in case of vista.
please help me how can i show ballon.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Without seeing your code, I have no idea what the mistake you're making is.
But if it works under Vista, I would guess you're using either a vista only function (unlikely), or using Vista only members of NOTIFYICONDATA.
My code from waaaaaay back when:
NOTIFYICONDATA niData;
memset (&niData, 0, sizeof(niData);
niData.cbSize = sizeof (niData);
niData.hWnd = m_hFrameWnd;
niData.uID = 99;
niData.uFlags = NIF_ICON;
niData.hIcon = m_hTaskBarIcons [0];
Shell_NotifyIcon (NIM_ADD, &niData);
http://msdn.microsoft.com/en-us/library/bb773352%28VS.85%29.aspx[^], and I see that there is indeed a vista extension.
#if (NTDDI_VERSION >= NTDDI_VISTA)
HICON hBalloonIcon;
#endif
So, you pass the size of the vista only structure in cbSize, and XP goes "huh".
Read the rest of the article, and it will point you to a constant that defines the size of the structure that XP can handle.
Good luck,
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
I m taking help of this article for system tray icon
Adding Icons to the System Tray[^]
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
It should work on XP.
Do you have SP2 installed?
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
What is the safe way to get the m_hThread handle?
One of few cases that construction hangs even if I change INFINITE to a second or so. It should be something with m_SomeThread object.
m_SomeThread is stored in MFC dialog.
Upon the user click, the AfxBeginThread is called, and m_SomeThread is assigned its return value.
I'm sure the thread does not hang in its body, as it posts the message to the dialog to report that it is finished.
Before creating another thread, the function waits for a single object in case user clicked too early and the thread has not yet terminated.
And one of few such calls the application freezes completely.
Чесноков
|
|
|
|
|
Did not really understand your question?
But I'm guess it has something to do with GetExitCodeThread[^].
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
|
Hi Yuriy,
Chesnokov Yuriy wrote: What is the safe way to get the m_hThread handle?
If the pointer to the thread is valid and the thread has not exited then the m_hThread handle is valid. You can use the GetExitCodeThread Function[^] to check if the thread is still active.
Chesnokov Yuriy wrote: And one of few such calls the application freezes completely.
What does your thread do? Are you interacting with a GUI thread?
Best Wishes,
-David Delaune
|
|
|
|