⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imagemagickobject.cpp

📁 下载来的一个看图软件的源代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
        case VT_I4:        case VT_I4 | VT_BYREF:        case VT_R4:        case VT_R4 | VT_BYREF:        case VT_R8:        case VT_R8 | VT_BYREF:        case VT_DECIMAL:        case VT_DECIMAL | VT_BYREF:        {          VARIANT variant;          bFoundOption = false;          VariantInit(&variant);          hr = VariantChangeTypeEx(&variant, pvarIndex, lcidDefault, 0, VT_BSTR);          if (SUCCEEDED(hr) && V_VT(&variant) == VT_BSTR)          {            hr = AddArgs(V_BSTR(&variant));          }          VariantClear(&variant);          break;        }        default:          ThrowPerformException(exception,MagickLib::ErrorException,            "Perform","Unsupported argument type");      }    }  }  LogInformation(methodName,"before execute");  MagickLib::ImageInfo    *image_info;  image_info=MagickLib::CloneImageInfo((MagickLib::ImageInfo *) NULL);#ifdef _DEBUG  //DebugBreak();#endif  hr = Execute(func,&text,image_info,exception);  MagickLib::DestroyImageInfo(image_info);  LogInformation(methodName,"after execute");  if (text != (char *) NULL)  {    CComVariant var;    var = text;    var.Detach(pVar);    MagickLib::LiberateMemory((void **) &text);  }  LogInformation(methodName,"return");  return hr;}void MagickImage::warninghandler(const MagickLib::ExceptionType warning,const char *message,  const char *qualifier){  char warning_text[MaxTextExtent];  if (!message)  {    LogInformation("warninghandler","called with no message");    return;  }  MagickLib::FormatString(warning_text,"warning %d: %.1024s%s%.1024s%s%s%.64s%s\n",warning,    message,qualifier ? " (" : "",qualifier ? qualifier : "",    qualifier? ")" : "",errno ? " [" : "",    errno ? strerror(errno) : "",errno ? "]" : "");  (void) MagickLib::LogMagickEvent(MagickLib::ResourceEvent,GetMagickModule(),warning_text);}void MagickImage::errorhandler(const MagickLib::ExceptionType warning,const char *message,  const char *qualifier){  char error_text[MaxTextExtent];  if (!message)  {    LogInformation("errorhandler","called with no message");    return;  }  MagickLib::FormatString(error_text,"error %d: %.1024s%s%.1024s%s%s%.64s%s\n",warning,    message,qualifier ? " (" : "",qualifier ? qualifier : "",    qualifier? ")" : "",errno ? " [" : "",    errno ? strerror(errno) : "",errno ? "]" : "");  (void) MagickLib::LogMagickEvent(MagickLib::ResourceEvent,GetMagickModule(),error_text);}void MagickImage::fatalerrorhandler(const MagickLib::ExceptionType error,const char *message,  const char *qualifier){  char fatalerror_text[MaxTextExtent];  if (!message)  {    LogInformation("fatalhandler","called with no message");    return;  }  MagickLib::FormatString(fatalerror_text,"fatal error %d: %.1024s%s%.1024s%s%s%.64s%s",error,    (message ? message : "ERROR"),    qualifier ? " (" : "",qualifier ? qualifier : "",qualifier ? ")" : "",    errno ? " [" : "",errno ? strerror(errno) : "",    errno? "]" : "");  (void) MagickLib::LogMagickEvent(MagickLib::ResourceEvent,GetMagickModule(),fatalerror_text);  DebugBreak();}HRESULT MagickImage::Execute(  unsigned int (*func)(MagickLib::ImageInfo *image_info,const int argc,char **argv,    char **text,MagickLib::ExceptionInfo *exception),      char **s, MagickLib::ImageInfo *image_info, MagickLib::ExceptionInfo *exception){  unsigned int retcode = 0;  retcode = (func)(image_info, GetArgc(), GetArgv(), s, exception);  if (!retcode)    return E_UNEXPECTED;  return S_OK;}HRESULT MagickImage::TestHarness(SAFEARRAY **pArrayVar, VARIANT *pVar){  HRESULT hr = S_OK;  (void) MagickLib::LogMagickEvent(MagickLib::ResourceEvent,GetMagickModule(),    "TestHarness");  MagickLib::ExceptionInfo    exception;  char    *reason,    *description,    message_text[MaxTextExtent];  reason = "unknown";  description = "unknown";  MagickLib::GetExceptionInfo(&exception);  CComVariant var;  if( !pArrayVar )   {    return E_INVALIDARG;  }  CComSafeArray<VARIANT> rg(*pArrayVar);  if( !rg )   {    return E_INVALIDARG;  }  if( rg.GetDimensions() != 1 )   {    ThrowPerformException(&exception,MagickLib::ErrorException,      "Perform","Multi dimensional array passed");  }  if( rg.GetType() != VT_VARIANT )   {    ThrowPerformException(&exception,MagickLib::ErrorException,      "Perform","Non VARIANT array type passed");  }  EmptyArgs();  AddArgs(L"-convert");  int iLastVal = rg.GetCount();  for( int i = 0; i < iLastVal; ++i )  {    {      CComVariant vt(rg[i]);      vt.ChangeType(VT_BSTR);      CW2T str(vt.bstrVal);      (void) MagickLib::LogMagickEvent(MagickLib::ResourceEvent,GetMagickModule(),        "arg: %s",(LPCTSTR)str);      hr = AddArgs(vt.bstrVal);    }  }  //__try  {    char *text;    MagickLib::ImageInfo *image_info;    image_info = MagickLib::CloneImageInfo((MagickLib::ImageInfo *) NULL);    text = (char *) NULL;    hr = Execute(MagickLib::ConvertImageCommand,&text,image_info,&exception);    MagickLib::DestroyImageInfo(image_info);    if (text != (char *) NULL)    {      var = text;      var.Detach(pVar);      MagickLib::LiberateMemory((void **) &text);    }    if (FAILED(hr))    {      if (exception.reason)        reason = exception.reason;      if (exception.description)        description = exception.description;    }  }  //__except(1)  //{  //  hr = E_UNEXPECTED;  //  reason = "exception";  //  description = translate_exception(_exception_code());  //}  if (FAILED(hr))  {    hr = MAKE_HRESULT(SEVERITY_ERROR,FACILITY_ITF,dwErrorBase+1001);    MagickLib::FormatString(message_text,"convert: %d: %.1024s: %.1024s",      exception.severity,reason, description);    CA2W str(message_text);#ifdef _DEBUG    DebugBreak();#endif    Error(str,__uuidof(IMagickImage),hr);  }  MagickLib::DestroyExceptionInfo(&exception);  return hr;}#define ENABLE_FULL_EXCEPTIONSSTDMETHODIMP MagickImage::Convert(SAFEARRAY **pArrayVar, VARIANT *pVar){  USES_CONVERSION;  HRESULT hr;  MagickLib::ExceptionInfo    exception;  char    *reason,    *description,    message_text[MaxTextExtent];  //unsigned char  //  *leaktest;  //leaktest=(unsigned char *) MagickLib::AcquireMemory(1024);#ifdef ENABLE_FULL_EXCEPTIONS  __try#endif  {    EmptyArgs();    AddArgs(L"-convert");    MagickLib::GetExceptionInfo(&exception);    reason = "unknown";    description = "unknown";    hr = Perform(MagickLib::ConvertImageCommand,pArrayVar,pVar,&exception);    if (FAILED(hr))    {      if (exception.reason)        reason = exception.reason;      if (exception.description)        description = exception.description;    }  }#ifdef ENABLE_FULL_EXCEPTIONS  __except(1)  {    hr = E_UNEXPECTED;    reason = "exception";    description = translate_exception(_exception_code());  }#endif  if (FAILED(hr))    {      hr = MAKE_HRESULT(SEVERITY_ERROR,FACILITY_ITF,dwErrorBase+1001);      MagickLib::FormatString(message_text,"convert: %d: %.1024s: %.1024s",        exception.severity,reason, description);#ifdef _DEBUG      //DebugBreak();#endif      Error(A2W(message_text),__uuidof(IMagickImage),hr);    }  MagickLib::DestroyExceptionInfo(&exception);  return hr;}STDMETHODIMP MagickImage::Composite(SAFEARRAY **pArrayVar, VARIANT *pVar){  USES_CONVERSION;  HRESULT hr;  MagickLib::ExceptionInfo    exception;  char    *reason,    *description,    message_text[MaxTextExtent];  __try  {    EmptyArgs();    AddArgs(L"-convert");    MagickLib::GetExceptionInfo(&exception);    reason = "unknown";    description = "unknown";    hr = Perform(MagickLib::CompositeImageCommand,pArrayVar,pVar,&exception);    if (FAILED(hr))    {      if (exception.reason)        reason = exception.reason;      if (exception.description)        description = exception.description;    }  }  __except(1)  {    hr = E_UNEXPECTED;    reason = "exception";    description = translate_exception(_exception_code());  }  if (FAILED(hr))    {      hr = MAKE_HRESULT(SEVERITY_ERROR,FACILITY_ITF,dwErrorBase+1001);      MagickLib::FormatString(message_text,"composite: %d: %.1024s: %.1024s",        exception.severity,reason, description);      Error(A2W(message_text),__uuidof(IMagickImage),hr);    }  MagickLib::DestroyExceptionInfo(&exception);  return hr;}HRESULT MagickImage::Mogrify(SAFEARRAY **pArrayVar, VARIANT *pVar){  USES_CONVERSION;  HRESULT hr;  MagickLib::ExceptionInfo    exception;  char    *reason,    *description,    message_text[MaxTextExtent];  __try  {    EmptyArgs();    AddArgs(L"-convert");    MagickLib::GetExceptionInfo(&exception);    reason = "unknown";    description = "unknown";    hr = Perform(MagickLib::MogrifyImageCommand,pArrayVar,pVar,&exception);    if (FAILED(hr))    {      if (exception.reason)        reason = exception.reason;      if (exception.description)        description = exception.description;    }  }  __except(1)  {    hr = E_UNEXPECTED;    reason = "exception";    description = translate_exception(_exception_code());  }  if (FAILED(hr))  {    hr = MAKE_HRESULT(SEVERITY_ERROR,FACILITY_ITF,dwErrorBase+1001);    MagickLib::FormatString(message_text,"mogrify: %d: %.1024s: %.1024s",        exception.severity,reason, description);    Error(A2W(message_text),__uuidof(IMagickImage),hr);  }  MagickLib::DestroyExceptionInfo(&exception);  return hr;}HRESULT MagickImage::Montage(SAFEARRAY **pArrayVar, VARIANT *pVar){  USES_CONVERSION;  HRESULT hr;  MagickLib::ExceptionInfo    exception;  char    *reason,    *description,    message_text[MaxTextExtent];  __try  {    EmptyArgs();    AddArgs(L"-convert");    MagickLib::GetExceptionInfo(&exception);    reason = "unknown";    description = "unknown";    hr = Perform(MagickLib::MontageImageCommand,pArrayVar,pVar,&exception);    if (FAILED(hr))    {      if (exception.reason)        reason = exception.reason;      if (exception.description)        description = exception.description;    }  }  __except(1)  {    hr = E_UNEXPECTED;    reason = "exception";    description = translate_exception(_exception_code());  }  if (FAILED(hr))    {      hr = MAKE_HRESULT(SEVERITY_ERROR,FACILITY_ITF,dwErrorBase+1001);      MagickLib::FormatString(message_text,"montage: %d: %.1024s: %.1024s",        exception.severity,reason, description);      Error(A2W(message_text),__uuidof(IMagickImage),hr);    }  MagickLib::DestroyExceptionInfo(&exception);  return hr;}HRESULT MagickImage::Identify(SAFEARRAY **pArrayVar, VARIANT *pVar){  USES_CONVERSION;  HRESULT hr;  MagickLib::ExceptionInfo    exception;  char    *reason,    *description,    message_text[MaxTextExtent];  __try  {    EmptyArgs();    AddArgs(L"-convert");    MagickLib::GetExceptionInfo(&exception);    reason = "unknown";    description = "unknown";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -