|
topic says all is there any?
thnx
|
|
|
|
|
there are dozens.
did you try searching this site? or Google?
|
|
|
|
|
i searched ... nothing , i wonder maybe i use bad key words !
|
|
|
|
|
actually i searched in articles for "jpg to bmp API" the answers was s.th else ! for example changing icons to ... !!! i also looked in my API book but i couldnt find , man plz hlp
|
|
|
|
|
If you don't need to write the JPEG decompression yourself,
here's the simplest way I know:
#include <atlimage.h>
...
CImage image;
image.Load(_T("c:\\some.jpg"));
image.Save(_T("c:\\some.bmp"), ImageFormatBMP);
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
do u know where can i get atlimage.h ??? CImage is a new class included with VC7 i think, but i use BC++
-- modified at 17:26 Thursday 25th October, 2007
|
|
|
|
|
V_shr wrote: CImage is a new class included with VC7 i think, but i dont use VisualStudio.NET
Ok, try this ...
ULONG dwToken;
Gdiplus::GdiplusStartupInput input;
Gdiplus::GdiplusStartupOutput output;
Gdiplus::Status status = Gdiplus::GdiplusStartup(&dwToken, &input, &output);
if(status == Gdiplus::Ok)
{
Gdiplus::Bitmap *pBitmap = new Gdiplus::Bitmap(L"c:\\some.jpg", FALSE);
CLSID bmpClsid;
GetEncoderClsid(L"image/bmp", &bmpClsid);
pBitmap->Save(L"c:\\some.bmp", &bmpClsid);
delete pBitmap;
Gdiplus::GdiplusShutdown(dwToken);
}
I took the GetEncoderClsId() function right from the GDI+ docs in the Platform SDK.
It looks like this:
int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
{
UINT num = 0;
UINT size = 0;
ImageCodecInfo* pImageCodecInfo = NULL;
GetImageEncodersSize(&num, &size);
if(size == 0)
return -1;
pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
if(pImageCodecInfo == NULL)
return -1;
GetImageEncoders(num, size, pImageCodecInfo);
for(UINT j = 0; j < num; ++j)
{
if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
{
*pClsid = pImageCodecInfo[j].Clsid;
free(pImageCodecInfo);
return j;
}
}
free(pImageCodecInfo);
return -1;
}
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
thnx , here its 3:00 pm , ill try it tomarrow
|
|
|
|
|
Please refer this[^]. Hope this will solve your purpose.
Regards,
Paresh.
|
|
|
|
|
Hello,
How do we know that array is emtry or not?
here is a piece of my code
char* pch = "";
char sEnglish[100] = "";
...
...
...
// if pch is "" and sEnglish is "" then
// this ((pch!="")||(sEnglish !="")) is true, why? it should not be true, it must be false, or am i doing wrong?
// if that is true, it fails on strcat("","")
if ((pch!="")||(sEnglish !=""))
{
strcat(sEnglish,pch);
}
how do we know that pch is ""? or not? and
why strcat function fails when both of input paramets are NULL?
thanks
-- modified at 16:00 Thursday 25th October, 2007
|
|
|
|
|
Try using STL strings instead.
std::string pch;
std::string sEnglish;
...
...
if(!pch.empty() || !sEnglish.empty())
sEnglish += pch;
|
|
|
|
|
thanks, but i am wondering
why strcat function fails when both of input parameters are NULL?
i am using strtok functins, that is why i need to use
char *pch;
char sEnglish[100],
or can we use string types for strtok function?
|
|
|
|
|
Gofur Halmuratov wrote: but i am wondering
why strcat function fails when both of input parameters are NULL?
They aren't "NULL". "" is a string literal containing an ASCII "NULL".
A NULL string would be
char *pch = NULL;
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
See here[^] for an example of getting the same results of strtok using STL.
|
|
|
|
|
Gofur Halmuratov wrote: how do we know that is pch is ""? or not?
In general, C arrays don't have a length attached to them so it's up
to you to keep track of array lengths and array contents.
In this case, since you're working with C "strings", which are arrays of chars,
you can use strlen()...
if (0 == strlen(pch))
{
// pch is empty
}
You can't compare C strings like this:
pch!="" <-- wrong! Here you're comparing two pointers!
You can use strcmp however:
if (0 = strcmp(pch, ""))
{
// pch is empty
}
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
thanks Mark,
it helped alot!!!
|
|
|
|
|
How can u compare the string using == operator
use strcmp function to compare the strings
Murali.S
|
|
|
|
|
Hi.
I need to load a dialog from a resource script, (.rc file), at runtime. I mean, the resource file is not in the project, it was created outside the project and then, at runtime, I have to bind a CDialog class with some DIALOG template present in this .rc file. Is it possible?
Thank you.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
Well, anything is possible To load a script (text file) you need a compiler, basically a C-compiler. This will be messy. If you need to do heavy modifications of the resources at runtime I would instead recommend 1) loading compiled resources in a DLL and 2) using UpdateResource.
|
|
|
|
|
Thank you for answer.
Ok, I understand.
But 2 more questions, please.
1)
I have a resource file, and I have to compile it using, in example, VC compiler, ok?. What are the compiler options, (or where could I find it), to compile that script file into a dll. I mean without need to create a DLL project and so on. Because the guys that will create the resource script file, they don't know nothing about programming, they just put controls here and there using the VC 6.0 resource editor and nothing more. Then I will run, in example, a bat file to compile some given .rc files into a DLL.
2) Then that dll file will be load it at runtime by a VC program, (an OCX in particular), and it will use that dialog from dll and bind it to an existing CDialog derivated class.
Confusing?,
I thought in all this because we need to display many kind of dialogs, (and everyday a new one), and we want them outside the main project.
Maybe there's an easier way to handle this, but I can't figure out.
Thank you very much.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
Ok, sounds reasonable. Compile the script.rc using rc (which is, I believe, in reality a preprocessor that converts stuff like BEGIN to { and END to }, DIALOG to a c struct and after that calling a C-compiler). The resource compiler produces a .res file, that you can link into a .dll with /DLL. Another option is to create a DLL project in MSVC and use the Project/Export makefile command in MSVC - you'll have a real fun experience trying to dechiper the output But it works
And then to load the dialog is a breeze; LoadLibrary and then LoadResource on the HMODULE returned, and then CreateDialog with the template loaded. Translate to the framework you're using.
|
|
|
|
|
Ok, I got it!
Thank you very much!
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
I am getting problem in ofstream and ifstream but only in vista envirnment with my visual studio 6.0 Visual C++ application.
I am trying to support drag and drop feature for my application vista. Instead of vertual lization i tried to save the drag and drop object file in the physical memory but When i am trying to ready the file if I do not create one more ofstream object it want read properly in vista. I can not write this kind of unknown code in my application. I need help to understand why my code required ofstream again after ifstream in order to read.
Where in one .cpp file producer application is creating one .txt file that has information of objects that is going to be dragged to the consumer application. That text file is created in the virtual memory so I changed the location to physical memory. as seen below.
That is all I have changed in producer side
CString fileNameWithoutPath = dbObjTransferID + ".txt";
/*char tmpPath[_MAX_PATH];*/
CString cTempPath= "C:\\Program Files\\Common Files\\";
//VERIFY(GetTempPath(_MAX_PATH, ctmpPath));
CString fullyQualifiedTmpFile;
fullyQualifiedTmpFile.Format("%s%s", cTempPath, fileNameWithoutPath);
ofstream outStream(fullyQualifiedTmpFile, ios::out | ios::trunc);
if (outStream.good())
{
Am_Default_Load_Save_Context.Reset();
Am_Default_Load_Save_Context.Save(outStream, Am_Value(listOfItemsToSave));
outStream.close();
*phGlobal = GlobalAlloc(GMEM_FIXED | GMEM_SHARE | GMEM_ZEROINIT,
fullyQualifiedTmpFile.GetLength() + 1);
const char * pStr = fullyQualifiedTmpFile;
memcpy(*phGlobal, pStr, fullyQualifiedTmpFile.GetLength());
bSuccess = TRUE;
}
else
bSuccess = FALSE;
IN THE CONSUMER SIDE:
I am opening the filed that I have created wich has object information and trying to read that file but if I do not put some ambiguious code in it, it want work without it. Once I try to create ifstream object to read that file, I HAVE TO CREATE ONE MORE OFSTREAM TO LET DATA READ CORRECTLY USING THE IFSTREAM FILE.
// copy the pFileName so that we can free the global memory.
CString fileName = pFileName;
GlobalUnlock(stgMedium.hGlobal);
GlobalFree(stgMedium.hGlobal);
ifstream inFile;
inFile.clear();
inFile.open(fileName, ios::in);
// This is the code I have to add in order to make drag and drop work.
// I DO NOT WHY ????
CString copyfileName = "C:\\dndNonUsedfile.txt";
ofstream nFile(copyfileName, ios::out);
if(inFile.good())
{
Am_Value amVal;
if(ReadTransferredDataFromFile(inFile, amVal))
if(amVal.Valid())
{
versionObj = amVal;
}
inFile.close();
CFile::Remove(fileName);
}
nFile.close(); //Code to support vista
Kreena Amin
Sr. software engineer
|
|
|
|
|
All i would like to do is read an XML file and create one.
I forgot how tricky this can be in C++ .
I am using things like:
MSXML2::IXMLDOMDocument2Ptr pDocument;
MSXML2::IXMLDOMElementPtr pDocRoot;
MSXML2::IXMLDOMElementPtr pFound_Element;
MSXML2::IXMLDOMNodePtr pTag;
In my stdafx.h
I placed :
#import <msxml4.dll>
using namespace MSXML2;
I keep getting Cannot open type library file: 'msxml4.dll': No such file or directory.
Has anyone done this before who can give some guidance/Help?
|
|
|
|
|
It's been a while since I used it but I would guess you don't have MSXML4 installed correctly (with any Service Packs) on your system. The installation should place it correctly and register it etc.
What version of Visual Studio and Windows are you running?
|
|
|
|