16 layers of ifs, Who dare challenge this?
-
I hope you have a 22 inch above screen.
bool UpdateImageFileWithGPSPosition(LPCTSTR lpszPictureFilePath, char* lat_lon)
{
LPCTSTR lpszModPictureFilePath = lpszPictureFilePath;IImagingFactory\* pImgFactory = NULL; IImage\* pImage = NULL; bool fIsClsFounded = false; GUID guidImageEncoderCls; HRESULT hr = S\_OK; hr = CoCreateInstance(CLSID\_ImagingFactory, NULL, CLSCTX\_INPROC\_SERVER, IID\_IImagingFactory, (void \*\*)&pImgFactory); if (SUCCEEDED(hr)) { IStream\* pFileStream = CreateStreamByFileName(lpszPictureFilePath); IImageDecoder\* pImageDecoder = 0; hr = pImgFactory->CreateImageDecoder(pFileStream, DecoderInitFlagNone, &pImageDecoder); if (SUCCEEDED(hr)) { ImageInfo imageInfo; hr = pImageDecoder->GetImageInfo(&imageInfo); if (SUCCEEDED(hr)) { UINT nEncodersCount = 0; ImageCodecInfo\* pEncoders = NULL; hr = pImgFactory->GetInstalledEncoders(&nEncodersCount, &pEncoders); if (SUCCEEDED(hr)) { for (UINT i = 0; i < nEncodersCount; i++) { if (pEncoders\[i\].FormatID == imageInfo.RawDataFormat) { guidImageEncoderCls = pEncoders\[i\].Clsid; fIsClsFounded = true; break; }//if }//for }//if // encoder founded now goes to properties if (fIsClsFounded) { PropertyItem pi; // add latitude { // add longitude pi.id = PropertyTagSoftwareUsed; pi.type = PropertyTagTypeASCII; pi.length = sizeof(char) \* 30; pi.value = lat\_lon; hr = pImageDecoder->SetPropertyItem(pi); if (SUCCEEDED(hr)) { IImageEncoder\* pImageEncoder = NULL; hr = pImgFactory->CreateImageEncoderToFile( &guidImageEncoderCls, lpszModPictureFilePath, &pImageEncoder); if (SUCCEEDED(hr)) { IImageSink\* pImageSink = NULL; hr = pImageEncoder->GetEncodeSink(&pImageSink); if (SUCCEEDED(hr)) { UINT uiPropertiesCount = 0; hr = pImageDecoder->GetPropertyCount(&uiPropertiesCount); if (SUCCEEDED(hr)) { UINT totalBufferSize = 0; UINT numProperties = 0; hr = pImageDecoder->GetPropertySize(&totalBufferSize, &numProperties); if (SUCCEEDED(hr)) { PropertyItem\* pis = (PropertyItem\*)malloc(totalBufferSize); hr = pImageDecode
kingsimba0511 wrote:
I hope you have a 22 inch above screen.
I don't have it :(
-
kingsimba0511 wrote:
I hope you have a 22 inch above screen.
I don't have it :(
And it fits my 20" monitor just fine. Even with the 8-SPACE indenting and large font.
-
I hope you have a 22 inch above screen.
bool UpdateImageFileWithGPSPosition(LPCTSTR lpszPictureFilePath, char* lat_lon)
{
LPCTSTR lpszModPictureFilePath = lpszPictureFilePath;IImagingFactory\* pImgFactory = NULL; IImage\* pImage = NULL; bool fIsClsFounded = false; GUID guidImageEncoderCls; HRESULT hr = S\_OK; hr = CoCreateInstance(CLSID\_ImagingFactory, NULL, CLSCTX\_INPROC\_SERVER, IID\_IImagingFactory, (void \*\*)&pImgFactory); if (SUCCEEDED(hr)) { IStream\* pFileStream = CreateStreamByFileName(lpszPictureFilePath); IImageDecoder\* pImageDecoder = 0; hr = pImgFactory->CreateImageDecoder(pFileStream, DecoderInitFlagNone, &pImageDecoder); if (SUCCEEDED(hr)) { ImageInfo imageInfo; hr = pImageDecoder->GetImageInfo(&imageInfo); if (SUCCEEDED(hr)) { UINT nEncodersCount = 0; ImageCodecInfo\* pEncoders = NULL; hr = pImgFactory->GetInstalledEncoders(&nEncodersCount, &pEncoders); if (SUCCEEDED(hr)) { for (UINT i = 0; i < nEncodersCount; i++) { if (pEncoders\[i\].FormatID == imageInfo.RawDataFormat) { guidImageEncoderCls = pEncoders\[i\].Clsid; fIsClsFounded = true; break; }//if }//for }//if // encoder founded now goes to properties if (fIsClsFounded) { PropertyItem pi; // add latitude { // add longitude pi.id = PropertyTagSoftwareUsed; pi.type = PropertyTagTypeASCII; pi.length = sizeof(char) \* 30; pi.value = lat\_lon; hr = pImageDecoder->SetPropertyItem(pi); if (SUCCEEDED(hr)) { IImageEncoder\* pImageEncoder = NULL; hr = pImgFactory->CreateImageEncoderToFile( &guidImageEncoderCls, lpszModPictureFilePath, &pImageEncoder); if (SUCCEEDED(hr)) { IImageSink\* pImageSink = NULL; hr = pImageEncoder->GetEncodeSink(&pImageSink); if (SUCCEEDED(hr)) { UINT uiPropertiesCount = 0; hr = pImageDecoder->GetPropertyCount(&uiPropertiesCount); if (SUCCEEDED(hr)) { UINT totalBufferSize = 0; UINT numProperties = 0; hr = pImageDecoder->GetPropertySize(&totalBufferSize, &numProperties); if (SUCCEEDED(hr)) { PropertyItem\* pis = (PropertyItem\*)malloc(totalBufferSize); hr = pImageDecode
kingsimba0511 wrote:
I hope you have a 22 inch above screen.
It's not the diagonal, it's the resolution. That fits comfortably on my 18" 1600x1200 CRT. I suspect it would fit on my 1400px wide laptop LCD as well.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots. -- Robert Royall
-
And it fits my 20" monitor just fine. Even with the 8-SPACE indenting and large font.
I have 17" monitor :-\
-
kingsimba0511 wrote:
I hope you have a 22 inch above screen.
It's not the diagonal, it's the resolution. That fits comfortably on my 18" 1600x1200 CRT. I suspect it would fit on my 1400px wide laptop LCD as well.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots. -- Robert Royall
And the font, I use 8-point.
-
And the font, I use 8-point.
I use browser default. I've never seen a font only scaling that didn't fubar page layouts at least somewhat. Opera's zoom probably comes closest but there're some video plugins it doesn't scale.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots. -- Robert Royall
-
Even so, it's easy enough to do something along the lines of:
success = Operation()
if (success == TRUE)
{
...
}if (success == TRUE)
{
...
}etc or
do {
success = Operation();
if (!success) break;success = Operation2();
if (!success) break;...
} while(false)cheers, Chris Maunder
CodeProject.com : C++ MVP
-
Or if it's just functions being called in sequence success = success && Operation1(); success = success && Operation2(); success = success && Operation3(); or more obfuscated... success = success && Operation1() && Operation2() && Operation3();
If there were nothing other than functions called in sequence, then one could use:
{
if (operation1())
return -1;
else if (operation2())
return -2;
else if (operation3())
return -3;
return 0; /* Success! */
}which is I think nicer than using the flag. The place the flag is helpful is when there are things going on other than the simple operations, e.g.
if (!error)
{
setup_for_operation2();
error = operation2();
}I'm not a particular fan of using the && operator; if one wants to put each operation on one line, one could code it as
if (!error) error = operation3();
which is clearer than the && version, is more versatile when zero is error case (the error flag will hold the particular error code returned, instead of having to hold zero or one), and may yield more efficient code if 0 is error and 1 is success (a statement like ok = ok && operation3(); is likely to perform a redundant write to ok when it's equal to zero.
-
I hope you have a 22 inch above screen.
bool UpdateImageFileWithGPSPosition(LPCTSTR lpszPictureFilePath, char* lat_lon)
{
LPCTSTR lpszModPictureFilePath = lpszPictureFilePath;IImagingFactory\* pImgFactory = NULL; IImage\* pImage = NULL; bool fIsClsFounded = false; GUID guidImageEncoderCls; HRESULT hr = S\_OK; hr = CoCreateInstance(CLSID\_ImagingFactory, NULL, CLSCTX\_INPROC\_SERVER, IID\_IImagingFactory, (void \*\*)&pImgFactory); if (SUCCEEDED(hr)) { IStream\* pFileStream = CreateStreamByFileName(lpszPictureFilePath); IImageDecoder\* pImageDecoder = 0; hr = pImgFactory->CreateImageDecoder(pFileStream, DecoderInitFlagNone, &pImageDecoder); if (SUCCEEDED(hr)) { ImageInfo imageInfo; hr = pImageDecoder->GetImageInfo(&imageInfo); if (SUCCEEDED(hr)) { UINT nEncodersCount = 0; ImageCodecInfo\* pEncoders = NULL; hr = pImgFactory->GetInstalledEncoders(&nEncodersCount, &pEncoders); if (SUCCEEDED(hr)) { for (UINT i = 0; i < nEncodersCount; i++) { if (pEncoders\[i\].FormatID == imageInfo.RawDataFormat) { guidImageEncoderCls = pEncoders\[i\].Clsid; fIsClsFounded = true; break; }//if }//for }//if // encoder founded now goes to properties if (fIsClsFounded) { PropertyItem pi; // add latitude { // add longitude pi.id = PropertyTagSoftwareUsed; pi.type = PropertyTagTypeASCII; pi.length = sizeof(char) \* 30; pi.value = lat\_lon; hr = pImageDecoder->SetPropertyItem(pi); if (SUCCEEDED(hr)) { IImageEncoder\* pImageEncoder = NULL; hr = pImgFactory->CreateImageEncoderToFile( &guidImageEncoderCls, lpszModPictureFilePath, &pImageEncoder); if (SUCCEEDED(hr)) { IImageSink\* pImageSink = NULL; hr = pImageEncoder->GetEncodeSink(&pImageSink); if (SUCCEEDED(hr)) { UINT uiPropertiesCount = 0; hr = pImageDecoder->GetPropertyCount(&uiPropertiesCount); if (SUCCEEDED(hr)) { UINT totalBufferSize = 0; UINT numProperties = 0; hr = pImageDecoder->GetPropertySize(&totalBufferSize, &numProperties); if (SUCCEEDED(hr)) { PropertyItem\* pis = (PropertyItem\*)malloc(totalBufferSize); hr = pImageDecode
This developer might not be as stupid as we think. Just think how impressed a business user ( with no concept of programming) must be when this code is shown to him/her. A business person will think that a developer that can write code that looks like this (extremely complex in the business users eyes) must be a genius and a great asset to the company. What better job security can you get?
If at first you don't succeed, failure may be your style. (Quentin Crisp) Recession is when a neighbor loses his job. Depression is when you lose yours. (Ronald Reagan)
-
I hope you have a 22 inch above screen.
bool UpdateImageFileWithGPSPosition(LPCTSTR lpszPictureFilePath, char* lat_lon)
{
LPCTSTR lpszModPictureFilePath = lpszPictureFilePath;IImagingFactory\* pImgFactory = NULL; IImage\* pImage = NULL; bool fIsClsFounded = false; GUID guidImageEncoderCls; HRESULT hr = S\_OK; hr = CoCreateInstance(CLSID\_ImagingFactory, NULL, CLSCTX\_INPROC\_SERVER, IID\_IImagingFactory, (void \*\*)&pImgFactory); if (SUCCEEDED(hr)) { IStream\* pFileStream = CreateStreamByFileName(lpszPictureFilePath); IImageDecoder\* pImageDecoder = 0; hr = pImgFactory->CreateImageDecoder(pFileStream, DecoderInitFlagNone, &pImageDecoder); if (SUCCEEDED(hr)) { ImageInfo imageInfo; hr = pImageDecoder->GetImageInfo(&imageInfo); if (SUCCEEDED(hr)) { UINT nEncodersCount = 0; ImageCodecInfo\* pEncoders = NULL; hr = pImgFactory->GetInstalledEncoders(&nEncodersCount, &pEncoders); if (SUCCEEDED(hr)) { for (UINT i = 0; i < nEncodersCount; i++) { if (pEncoders\[i\].FormatID == imageInfo.RawDataFormat) { guidImageEncoderCls = pEncoders\[i\].Clsid; fIsClsFounded = true; break; }//if }//for }//if // encoder founded now goes to properties if (fIsClsFounded) { PropertyItem pi; // add latitude { // add longitude pi.id = PropertyTagSoftwareUsed; pi.type = PropertyTagTypeASCII; pi.length = sizeof(char) \* 30; pi.value = lat\_lon; hr = pImageDecoder->SetPropertyItem(pi); if (SUCCEEDED(hr)) { IImageEncoder\* pImageEncoder = NULL; hr = pImgFactory->CreateImageEncoderToFile( &guidImageEncoderCls, lpszModPictureFilePath, &pImageEncoder); if (SUCCEEDED(hr)) { IImageSink\* pImageSink = NULL; hr = pImageEncoder->GetEncodeSink(&pImageSink); if (SUCCEEDED(hr)) { UINT uiPropertiesCount = 0; hr = pImageDecoder->GetPropertyCount(&uiPropertiesCount); if (SUCCEEDED(hr)) { UINT totalBufferSize = 0; UINT numProperties = 0; hr = pImageDecoder->GetPropertySize(&totalBufferSize, &numProperties); if (SUCCEEDED(hr)) { PropertyItem\* pis = (PropertyItem\*)malloc(totalBufferSize); hr = pImageDecode
And the comments on the terminating braces are useless, too.
Professional Geek, Amateur Stage-Levelling Gauge
-
I hope you have a 22 inch above screen.
bool UpdateImageFileWithGPSPosition(LPCTSTR lpszPictureFilePath, char* lat_lon)
{
LPCTSTR lpszModPictureFilePath = lpszPictureFilePath;IImagingFactory\* pImgFactory = NULL; IImage\* pImage = NULL; bool fIsClsFounded = false; GUID guidImageEncoderCls; HRESULT hr = S\_OK; hr = CoCreateInstance(CLSID\_ImagingFactory, NULL, CLSCTX\_INPROC\_SERVER, IID\_IImagingFactory, (void \*\*)&pImgFactory); if (SUCCEEDED(hr)) { IStream\* pFileStream = CreateStreamByFileName(lpszPictureFilePath); IImageDecoder\* pImageDecoder = 0; hr = pImgFactory->CreateImageDecoder(pFileStream, DecoderInitFlagNone, &pImageDecoder); if (SUCCEEDED(hr)) { ImageInfo imageInfo; hr = pImageDecoder->GetImageInfo(&imageInfo); if (SUCCEEDED(hr)) { UINT nEncodersCount = 0; ImageCodecInfo\* pEncoders = NULL; hr = pImgFactory->GetInstalledEncoders(&nEncodersCount, &pEncoders); if (SUCCEEDED(hr)) { for (UINT i = 0; i < nEncodersCount; i++) { if (pEncoders\[i\].FormatID == imageInfo.RawDataFormat) { guidImageEncoderCls = pEncoders\[i\].Clsid; fIsClsFounded = true; break; }//if }//for }//if // encoder founded now goes to properties if (fIsClsFounded) { PropertyItem pi; // add latitude { // add longitude pi.id = PropertyTagSoftwareUsed; pi.type = PropertyTagTypeASCII; pi.length = sizeof(char) \* 30; pi.value = lat\_lon; hr = pImageDecoder->SetPropertyItem(pi); if (SUCCEEDED(hr)) { IImageEncoder\* pImageEncoder = NULL; hr = pImgFactory->CreateImageEncoderToFile( &guidImageEncoderCls, lpszModPictureFilePath, &pImageEncoder); if (SUCCEEDED(hr)) { IImageSink\* pImageSink = NULL; hr = pImageEncoder->GetEncodeSink(&pImageSink); if (SUCCEEDED(hr)) { UINT uiPropertiesCount = 0; hr = pImageDecoder->GetPropertyCount(&uiPropertiesCount); if (SUCCEEDED(hr)) { UINT totalBufferSize = 0; UINT numProperties = 0; hr = pImageDecoder->GetPropertySize(&totalBufferSize, &numProperties); if (SUCCEEDED(hr)) { PropertyItem\* pis = (PropertyItem\*)malloc(totalBufferSize); hr = pImageDecode
-
Even so, it's easy enough to do something along the lines of:
success = Operation()
if (success == TRUE)
{
...
}if (success == TRUE)
{
...
}etc or
do {
success = Operation();
if (!success) break;success = Operation2();
if (!success) break;...
} while(false)cheers, Chris Maunder
CodeProject.com : C++ MVP
How about
try
{
hr = Operation1();
if (!SUCCESS(hr)) throw hr;hr = Operation2(); if (!SUCCESS(hr)) throw hr; hr = Operator3(); if (!SUCCESS(hr)) throw hr; // ...
}
catch (HRESULT hErr)
{
// ...
}?
-
I hope you have a 22 inch above screen.
bool UpdateImageFileWithGPSPosition(LPCTSTR lpszPictureFilePath, char* lat_lon)
{
LPCTSTR lpszModPictureFilePath = lpszPictureFilePath;IImagingFactory\* pImgFactory = NULL; IImage\* pImage = NULL; bool fIsClsFounded = false; GUID guidImageEncoderCls; HRESULT hr = S\_OK; hr = CoCreateInstance(CLSID\_ImagingFactory, NULL, CLSCTX\_INPROC\_SERVER, IID\_IImagingFactory, (void \*\*)&pImgFactory); if (SUCCEEDED(hr)) { IStream\* pFileStream = CreateStreamByFileName(lpszPictureFilePath); IImageDecoder\* pImageDecoder = 0; hr = pImgFactory->CreateImageDecoder(pFileStream, DecoderInitFlagNone, &pImageDecoder); if (SUCCEEDED(hr)) { ImageInfo imageInfo; hr = pImageDecoder->GetImageInfo(&imageInfo); if (SUCCEEDED(hr)) { UINT nEncodersCount = 0; ImageCodecInfo\* pEncoders = NULL; hr = pImgFactory->GetInstalledEncoders(&nEncodersCount, &pEncoders); if (SUCCEEDED(hr)) { for (UINT i = 0; i < nEncodersCount; i++) { if (pEncoders\[i\].FormatID == imageInfo.RawDataFormat) { guidImageEncoderCls = pEncoders\[i\].Clsid; fIsClsFounded = true; break; }//if }//for }//if // encoder founded now goes to properties if (fIsClsFounded) { PropertyItem pi; // add latitude { // add longitude pi.id = PropertyTagSoftwareUsed; pi.type = PropertyTagTypeASCII; pi.length = sizeof(char) \* 30; pi.value = lat\_lon; hr = pImageDecoder->SetPropertyItem(pi); if (SUCCEEDED(hr)) { IImageEncoder\* pImageEncoder = NULL; hr = pImgFactory->CreateImageEncoderToFile( &guidImageEncoderCls, lpszModPictureFilePath, &pImageEncoder); if (SUCCEEDED(hr)) { IImageSink\* pImageSink = NULL; hr = pImageEncoder->GetEncodeSink(&pImageSink); if (SUCCEEDED(hr)) { UINT uiPropertiesCount = 0; hr = pImageDecoder->GetPropertyCount(&uiPropertiesCount); if (SUCCEEDED(hr)) { UINT totalBufferSize = 0; UINT numProperties = 0; hr = pImageDecoder->GetPropertySize(&totalBufferSize, &numProperties); if (SUCCEEDED(hr)) { PropertyItem\* pis = (PropertyItem\*)malloc(totalBufferSize); hr = pImageDecode
16 layers...that guy must be insane :~
modified on Friday, February 27, 2009 6:54 AM