c++ - Deep copy of CImage object causes debug assertion failed -


I have a problem similar to this problem: I need to make a deep copy of the CImage object. The specific problem is that I am getting CIMEZ * from a secondary thread through PostMessage, and it is a copy of the CIEISE object that is characterized by different classes.

I currently have the following code:

  LRESULT CMainFrame :: Transchange Transpole (UINT Vermom, Long Laparam) {DB ("Message Received \ n"); // This debug message is CImage output * ObraZel = (CImage *) wParam; Int a; CSTering T; Seymour Timzza; Obrazek- & gt; Save (_T ("mesydz.jpg")); // If the image is valid DEB ("o1 \ n"), check it; obrazek-> GetDC (); PointerToViewClass- & gt; Przetransformowany.Create (obrazek-> GetWidth (), obrazek-> GetHyight (), obrazek-> GetBPP ()); Deb ("o2 \ n"); obrazek-> BitBlt (PointerToViewClass-> przetransformowany.GetDC (), 0,0, SRCCOPY); // logger-> Release Dadi (); Deb ("o8 \ n"); PointerToViewClass- & gt; Przetransformowany.ReleaseDC (); Deb ("O6 \ n"); Deb ("O7 \ n"); obrazek-> ReleaseDC (); // remove obbras; Return 0; }   

I suspect that there is something wrong with obrazek-> GetDC () and obrazek-> ReleaseDC (). I do not have any errors when I have Obrozik-> GetDC () but otherwise the debug claim has failed on obrazek-> BitBlt (...);) although I am unable to release the DC of Obcache and / Object, which I want to do, because I'm leaking memory if I do not do that.

So in general there is something that I do not know about copying the object.

Edit:

The other thread handles CImage in the following manner:

  CImage wyniczek; CImage * Doprzezellenia; Objekt-> Project Transform (Massciers, and Weinike); / Object DLL is a component of the declaration class in Drpazelenia = new CImage (WinnieJack); PostMessage (Data-> Parents, MY_WM_MESSAGE4, ​​(wParam) doprzeslania, (lParam) 3); Delete objects; FreeLibrary (hDLL); Delete data; // remove an object with thread settings for return 0;   

Also, what is happening in the DLL with the image:

  zero processing :: apply transform (study :: vector & lt; double) & Gt; Matrix, CIJZ * Rezult) // // Here some image processing // output.Create (dest.cols, dest.rows, 24); Bitmapinfo BMI; // It has been properly initialized, it was erased for clarity StretchDIBits (output.GetDC (), 0,0, dest.cols, dest.rows, 0,0, dest.cols, dest.rows, Temp.data, & amp; BMI, DIB_RGB_COLORS, SRCCOPY); // Create CImage Result-> GP (Copy) from open CV matte object (output. Gatewidth), output. GateHight (), 24); Output.BitBlt (rezult-> GetDC (), 0,0, SRCCOPY); // copy CImage * rezult output. ReleaseDC (); Rezult-> ReleaseDC (); }    

Finally I came here with what was going wrong!

The problem was that, in the secondary thread, I was returning the CIMS object to another CImage object (which was on the stack):

  CImage wyniczek; objekt-> ApplyTransform (macierz, & wyniczek);   

and then copy it with the copy constructor with a new object built on the heap:

  CImage * doprzeslania; Doprazelynia = new ciimaz (wine); Generally speaking, the Dopzelania object was valid only until the secondary thread was running, which resulted in strange behavior, which was able to properly secure it at the beginning of the function. Who was receiving a post message, but was unable to copy it to another object. Its solution was to get the image directly into the * Dopzelania object from the function:  
  CImage * doprzeslania; Doprzelynia = new ciimage (); objekt-> ApplyTransform (macierz, doprzeslania);   

Now I have a problem displaying this image on the screen, but before I will ask another question, I will have to look closely through it. Thanks everyone for the fear!

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -