c++ cli - A generic error occurred in GDI+ while encoding -


i working ocr project. trying using open source project source code. project written in c++. when run project shows me exception “a generic error occurred in gdi+”.i've tried other stackoverflow solutions nothing works. find exception happen new it. so, don’t have idea exception. exception occurring here:

myencoderparameters->param[0] = myencoderparameter; 

the whole function is

bool imageprocessor::save_uc_tif_imagefromsegmentedinformation(vector<vector<bool>> img, int temporaryfilenumber){      try{         bitmap^ nimg = gcnew bitmap(wd, ht, pixelformat::format1bppindexed);                          lineindicator = 1;           //lock bits of original bitmap         bitmapdata^ bmdo = nimg->lockbits(rectangle(0, 0, wd, ht),                                imagelockmode::readwrite, nimg->pixelformat);               lineindicator = 2;          for(int x=0; x<ht; x++){             for(int y=0; y<wd; y++){                 if(img[x][y]){                     this->setindexedpixel(y, x, bmdo, 1);                 }else                 {                     this->setindexedpixel(y, x, bmdo, 0);                 }             }         }          //system::drawing::image::setpropertyitem(         nimg->unlockbits(bmdo);         lineindicator = 3;          // need set compression information here         imagecodecinfo^ ico = getencoderinfo(imageformat::tiff);         lineindicator = 4;         // create encoder object based on guid compression parameter category.         encoder^ myencoder = encoder::compression;         //encoder^ myencoder = encoder::quality;          lineindicator = 5;         // create encoderparameters object. encoderparameters object has array of encoderparameter objects.          // in case, there 1 encoderparameter object in array.         encoderparameters^ myencoderparameters = gcnew encoderparameters(1);         lineindicator = 6;         encoderparameter^ myencoderparameter = gcnew encoderparameter(myencoder,   __int64(20));           lineindicator = 7;         myencoderparameters->param[0] = myencoderparameter;         lineindicator = 8;          nimg->save(system::windows::forms::application::startuppath + "\\tesseract\\temp"+ temporaryfilenumber +".tif", ico, myencoderparameters);         lineindicator = 9;         return true;     }     catch(system::exception^ ex)     {         system::windows::forms::messagebox::show(ex->message->tostring(), "failed process  image  !!"+lineindicator,system::windows::forms::messageboxbuttons::ok,system::windows::forms::messageboxicon::error);         return false;     } } 

please fixing problem. in advance.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -