c++ cli - Debug Assertion Failed with rgbConverted.cpp -
first saying, it's duplicate question, not same problem.
when run code, message showing, no error.
#pragma once using namespace system::drawing; ref class rgbconvert { private: system::drawing::bitmap^ grayimage; system::drawing::bitmap^ bainaryimage; system::drawing::bitmap^ rgbimage; int xsize; int ysize; bool **barray; int **grayarray; int **binary; file *fp; static float coef01 = (float)0.2989; static float coef02 = (float)0.5870; static float coef03 = (float)0.1140; public: rgbconvert(system::drawing::bitmap^ im) { rgbimage = im; xsize = rgbimage->height; ysize = rgbimage->width; } rgbconvert(int height, int width) { xsize = height; ysize = width; } int** getgrayimagearray () { grayarray = new int * [xsize]; (int = 0; < xsize; i++ ) { grayarray[i] = new int[ysize]; } for( int = 0; < this->xsize; i++ ) { ( int j = 0; j < this->ysize; j++ ) { system::drawing::color^ clr = this->rgbimage->getpixel(j, i); int pixel = clr->toargb(); //int alpha = (pixel >> 24) & 0xff;// no need here int red = (pixel >> 16) & 0xff; int green = (pixel >> 8) & 0xff; int blue = (pixel ) & 0xff; int grayc = int(coef01*red + coef02*green + coef03*blue); grayarray[i][j] = grayc; }// inner for*/ } return grayarray; } void getgrayimagearray (int** garray) { this->grayarray = garray; } bool** getbinaryarray( int level ) { barray = new bool * [xsize]; (int = 0; < xsize; i++ ) { barray[i] = new bool[ysize]; } binary = new int * [xsize]; (int = 0; < xsize; i++ ) { binary[i] = new int[ysize]; } fp=fopen("c:\\binary.txt","w"); int grayc; ( int xval = 0; xval < xsize; xval++ ) { for( int yval = 0; yval < ysize; yval++ ) { grayc = grayarray[xval][yval]; if ( grayc >= level ) { barray[xval][yval] = true; binary[xval][yval] = 1; fprintf(fp,"%d",binary[xval][yval]); } else { barray[xval][yval] = false; binary[xval][yval] = 0; fprintf(fp,"%d",binary[xval][yval]); } }// inner for*/ } fclose(fp); return barray; } };
when press retry, breakpoint showing line.
fprintf(fp,"%d",binary[xval][yval]);
if remove these lines showing breakpoint in main program.
int main(array<system::string ^> ^args) { // enabling windows xp visual effects before controls created application::enablevisualstyles(); application::setcompatibletextrenderingdefault(false); // create main window , run application::run(gcnew form1()); return 0; }
breakpoint showing in return 0
line.
actually known problem. have solved topics. in code had created text files, docx files , images in c drives. there no permission accessing c drive in computer. had solved following steps:
if can access cmd, can reset security settings in vista/windows 7 following command: "secedit /configure /cfg %windir%\inf\defltbase.inf /db defltbase.sdb /verbose" (no quotes.) see command does, go here: how restore security settings default settings?
note: if can't access cmd when logged in, use guide system recovery options. can command line when access system recovery options screen.
this command seems give ownership issue kick backside, though seems nothing has changed. go explorer, right click on c: , go properties.
go security tab , advanced.
go owner tab. should able click edit.
if don't have administrators in list under says "change owner to:" go "other users or groups". if do, go straight step 7.
on others users or groups type in "administrators" (no quotes) in bottom box. click check name , ok.
click administrators , ok. you've given ownership of c:! (as long account administrator, is.)
click ok on "advanced security settings..." window properties window. should have list of permissions , on before had how couldn't view permissions. progress, eh?
you may need add in adminstrators group edit permissions. this, click "edit" , "add" , type "administrators" (no quotes) in bottom box. hit check name , ok.
click administrators in list , tick box in allow column next "full control".
click apply, you'll bunch of error messages how can't applied files , folders. ok through them all. once done, should have access c: drive once more!
Comments
Post a Comment