|
Hi
Here you got all code you need:
http://www.codeproject.com/bitmap/cximage.asp
Daniel
|
|
|
|
|
Mahesh Varma wrote:
Is there any free libs ?
there are probably ten different libs here on code project. try looking around a little bit.
-c
Image tools: ThumbNailer, Bobber, TIFFAssembler
|
|
|
|
|
Use GDI+ .
Take a sample from MSDN: "Setting JPEG Compression Level"
#include <windows.h>
#include <gdiplus.h>
#include <stdio.h>
using namespace Gdiplus;
INT GetEncoderClsid(const WCHAR* format, CLSID* pClsid);
INT main()
{
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
CLSID encoderClsid;
EncoderParameters encoderParameters;
ULONG quality;
Status stat;
Image* image = new Image(L"Shapes.bmp");
GetEncoderClsid(L"image/jpeg", &encoderClsid);
encoderParameters.Count = 1;
encoderParameters.Parameter[0].Guid = EncoderQuality;
encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
encoderParameters.Parameter[0].NumberOfValues = 1;
quality = 0;
encoderParameters.Parameter[0].Value = &quality;
stat = image->Save(L"Shapes001.jpg", &encoderClsid, &encoderParameters);
if(stat == Ok)
wprintf(L"%s saved successfully.\n", L"Shapes001.jpg");
else
wprintf(L"%d Attempt to save %s failed.\n", stat, L"Shapes001.jpg");
quality = 50;
encoderParameters.Parameter[0].Value = &quality;
stat = image->Save(L"Shapes050.jpg", &encoderClsid, &encoderParameters);
if(stat == Ok)
wprintf(L"%s saved successfully.\n", L"Shapes050.jpg");
else
wprintf(L"%d Attempt to save %s failed.\n", stat, L"Shapes050.jpg");
quality = 100;
encoderParameters.Parameter[0].Value = &quality;
stat = image->Save(L"Shapes100.jpg", &encoderClsid, &encoderParameters);
if(stat == Ok)
wprintf(L"%s saved successfully.\n", L"Shapes100.jpg");
else
wprintf(L"%d Attempt to save %s failed.\n", stat, L"Shapes100.jpg");
delete image;
GdiplusShutdown(gdiplusToken);
return 0;
}
|
|
|
|
|
If you are using VC++ .NET ,then use CImage class
|
|
|
|
|
How can I list all exported functions in a dll like "dependency walker" from Microsoft...
|
|
|
|
|
Hail AnTri,
You can use dumpbin.exe. It has a lot of options.
To see all exports use dumpbin /exports <file.dll>
Regards.
|
|
|
|
|
Thank you, but you misunderstand me.
I need a function in my Application that list's all exported function from a selected dll.
|
|
|
|
|
Download from MSDN the sample PEDump in article "Peering Inside the PE: A Tour of the Win32 Portable Executable File Format".
However, the function DumpExportsSection doesn't work since it looks for
the section ".edata" which sometimes is contained in ".rdata" section.
Therefore i put some changes according to other sample.
Add the following at the beginning of EXEDump.c :
#define GetImgDirEntryRVA( pNTHdr, IDE ) \
(pNTHdr->OptionalHeader.DataDirectory[IDE].VirtualAddress)
#define GetImgDirEntrySize( pNTHdr, IDE ) \
(pNTHdr->OptionalHeader.DataDirectory[IDE].Size)
PIMAGE_SECTION_HEADER GetEnclosingSectionHeader(DWORD rva, PIMAGE_NT_HEADERS pNTHeader)
{
PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(pNTHeader);
unsigned i;
for ( i=0; i < pNTHeader->FileHeader.NumberOfSections; i++, section++ )
{
DWORD size = section->Misc.VirtualSize;
if ( 0 == size )
size = section->SizeOfRawData;
if ( (rva >= section->VirtualAddress) &&
(rva < (section->VirtualAddress + size)))
return section;
}
return 0;
}
LPVOID GetPtrFromRVA( DWORD rva, PIMAGE_NT_HEADERS pNTHeader, PBYTE imageBase )
{
PIMAGE_SECTION_HEADER pSectionHdr;
INT delta;
pSectionHdr = GetEnclosingSectionHeader( rva, pNTHeader );
if ( !pSectionHdr )
return 0;
delta = (INT)(pSectionHdr->VirtualAddress-pSectionHdr->PointerToRawData);
return (PVOID) ( imageBase + rva - delta );
}
Replace the function DumpExportsSection with the new one:
void DumpExportsSection(DWORD base, PIMAGE_NT_HEADERS pNTHeader)
{
PIMAGE_EXPORT_DIRECTORY exportDir;
PIMAGE_SECTION_HEADER header;
INT delta;
PSTR filename;
DWORD i;
PDWORD functions;
PWORD ordinals;
PSTR *name;
DWORD exportsStartRVA, exportsEndRVA;
exportsStartRVA = GetImgDirEntryRVA(pNTHeader,IMAGE_DIRECTORY_ENTRY_EXPORT);
exportsEndRVA = exportsStartRVA +
GetImgDirEntrySize(pNTHeader, IMAGE_DIRECTORY_ENTRY_EXPORT);
header = GetEnclosingSectionHeader( exportsStartRVA, pNTHeader );
if ( !header )
return;
delta = (INT)(header->VirtualAddress - header->PointerToRawData);
exportDir = (PIMAGE_EXPORT_DIRECTORY)GetPtrFromRVA(exportsStartRVA, pNTHeader, base);
filename = (PSTR)(exportDir->Name - delta + base);
printf("exports table:\n\n");
printf(" Name: %s\n", filename);
printf(" Characteristics: %08X\n", exportDir->Characteristics);
printf(" TimeDateStamp: %08X\n", exportDir->TimeDateStamp);
printf(" Version: %u.%02u\n", exportDir->MajorVersion,
exportDir->MajorVersion);
printf(" Ordinal base: %08X\n", exportDir->Base);
printf(" # of functions: %08X\n", exportDir->NumberOfFunctions);
printf(" # of Names: %08X\n", exportDir->NumberOfNames);
functions = (PDWORD)((DWORD)exportDir->AddressOfFunctions - delta + base);
ordinals = (PWORD)((DWORD)exportDir->AddressOfNameOrdinals - delta + base);
name = (PSTR *)((DWORD)exportDir->AddressOfNames - delta + base);
printf("\n Entry Pt Ordn Name\n");
for ( i=0; i < exportDir->NumberOfNames; i++ )
{
printf(" %08X %4u %s\n", *functions,
*ordinals + exportDir->Base,
(*name - delta + base));
name++;
ordinals++;
functions++;
}
}
Anyway, if you want me to email you the full sample then send me your
e-mail.
Dudi
|
|
|
|
|
Hello.
i have a little problem.
I have an SDI project. Left pano is CListView and right is CFormView.
It is about the CListView. It uses a standart CListCtrl class which is not very usefull for me. SO i found a source
of extended CListCtrl --> XListCtrl. This is a good class, BUT i dont know how to replace a standart CListCtrl
in the CListView with this XListCtrl.
Any ideas.
Thank you in advance.
|
|
|
|
|
Make the ListView pane a class derived from CFormView , with the XListCtrl on it occupying the whole space, growing and shrinking with the pane.
For this, have your View handle WM_SIZE and SetWindow() your XListCtrl to the size of the pane.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
How to change a text on a submenu item??
This is how I enableMenuItem and it works but how to chege the text on it???
UINT ID = ::GetMenuItemID(pSubMenu->m_hMenu,0);
::EnableMenuItem(pSubMenu->m_hMenu,ID,0);
|
|
|
|
|
|
Take a look at the documentation for the CMenu class. You can use for several purpose (also if you want to change the text).
You can use the ModifyItem function.
Suppose the ID of the menu item you want to change the text is ID_YOURID and the menu is ID_YOURMENU. Use the following code:
CMenu* pNewMenu = new CMenu();<br />
pNewMenu->LoadMenu(ID_YOURMENU);<br />
pNewMenu->ModifyMenu(ID_YOURID,MF_BYCOMMAND|MF_STRING,ID_YOURID,"Your Text");<br />
Call then TpNewMenu->TrackPopupMenu(...) to show the menu!
Hope this helps!
|
|
|
|
|
Does anybody know of a library for unzipping files other than the article here on CP [nothing wrong with that one] but I'm just wondering.
Regards,
Brian Dela
|
|
|
|
|
zLib[^]is THE one and only standard!
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
hello,
I use Scroll window to scroll a view in child window.
how to "ScrollTo(0,0)", i want to reposition my view.
i have already use SetWindowPos(0,0,0,0,0,SWP_NOSIZE) , but it seems doesn't work.
thx in advance
|
|
|
|
|
|
thx but i work with CHtmlView and i can't use SetScrollPos without error
another idea ?
thx again
|
|
|
|
|
CHtmlView ...
BOOL CMyHtmlView::ScrollTop(
LPDISPATCH pdispDoc, // The HTML document to scroll
BOOL bScrollTop) // TRUE=top;FALSE=bottom
{
CComQIPtr<ihtmldocument2>piDoc(pdispDoc);
CComPtr<ihtmlwindow2>piWindow;
return (piDoc && SUCCEEDED(piDoc->get_parentWindow(
&piWindow)) && piWindow && SUCCEEDED(piWindow->scroll(
0, (bScroll) ? LONG_MIN : LONG_MAX)));
}
|
|
|
|
|
thx for your help
but i don't want to use the scrollbar of CHtmlView, there are a lot of problem with there (i can't control scrollbar with some web site). I search a function like "ScrollTo(X,Y) " but it seems it doesn't exist
thank you nevertheless
|
|
|
|
|
Hi
I'm using hooks to subclass menus so I can draw them myself. This works pretty good on Windows XP, but on 98 and 2000 it only seems to work once. When I have two different programs using the new style menus I can start up one of them over and over again without problems. But as soon as I click on a menu in another app using the menus it crashes. It only happens with a menu attached to a window. When using TrackPopupMenu it always seems to work. Any suggestions?
Thanks
|
|
|
|
|
i want to know how to replace simple buttons with bitmaps.
I dont want to use derived classes or CBITMAPBUTTON .
I tried using CButton::Setbitmap but it wasnt working.
Please explain thoroughly how to do it.
|
|
|
|
|
hi yashraj,
The method for using CBitmapButton class is clearly mentioned in MSDN.
To include a bitmap-button control in a dialog box, follow these steps:
1. Create one to four bitmap images for the button.
2. Create a dialog template with an owner-draw button positioned where you want the bitmap button. The size of the button in the template does not matter.
3.Set the button’s caption to a value such as “TEST” and define a symbol for the button such as IDC_TEST.
4.In your application’s resource script, give each of the images created for the button an ID constructed by appending one of the letters “U,” “D,” “F,” or “X” (for up, down, focused, and disabled) to the string used for the button caption in step 3. For the button caption “TEST,” for example, the IDs would be “TESTU,” “TESTD,” “TESTF,” and “TESTX.” You must specify the ID of your bitmaps within double quotes. Otherwise the resource editor will assign an integer to the resource and MFC will fail when loading the image.
5.In your application’s dialog class (derived from CDialog), add a CBitmapButton member object.
6.In the CDialog object’s OnInitDialog routine, call the CBitmapButton object’s AutoLoad function, using as parameters the button’s control ID and the CDialog object’s this pointer.
Mahesh Varma
|
|
|
|
|
ALREADY TOLD THAT I DONT WANT TO USE " CBitmapButton "
|
|
|
|
|
Is there any way of changing style of a dialog box from not resizable to resizable and back at run-time?
Regards,
Vitaly Tomilov
Professional tooltips for all development platforms Free on www.Tooltips.NET
|
|
|
|
|