Memory usage while printing
-
Sorry for my very bad english.
I mean if call painter.drawImage in my loop, a lot of memory is used like 2Go for example.for(OdInt32 u = 0; u < iHorizontalTileCount; u++) { OdInt32 printerY = iVStep == 1 ? 0 : uiHeight; for(OdInt32 v = 0; v < iVerticalTileCount; v++) { OdUInt32 uiCurrentTileWidth = odmin(uiTileWidth, uiWidth - (uiTileWidth * u)); OdUInt32 uiCurrentTileHeight = odmin(uiTileHeight, uiHeight - (uiTileHeight * v)); OdInt32 tileX = u * uiTileWidth; OdInt32 tileY = v * uiTileHeight; OdGsDCRect tileRect(tileX, tileX + uiCurrentTileWidth, tileY, tileY + uiCurrentTileHeight); OdGsDCRect snapShotRegion = regenTile(viewportSize, tileRect); //render image OdGiRasterImagePtr pImage; m_pTeighaPrinter->getSnapShot(pImage, snapShotRegion); width = pImage->pixelWidth(); height = pImage->pixelHeight(); const OdUInt8* pData = pImage->scanLines(); // create image QImage qtImg((const uchar *) pData, width, height, fmt); // paint painter.drawImage(iHStep == 1 ? printerX : (printerX - width), iVStep == 1 ? printerY : (printerY - height), qtImg,0, 0, width, height); printerY += iVStep * height; if(!bRestored) { pCoreApp->setMtMode(iMtMode); bRestored = true; } // progression emit sg_progress(iProgress); iProgress++; } printerX += iHStep * width; }
If I remove line painter.drawImage and store image on list, the memory is not growing.
I would not pretend that's a memory leak but my problem is like a memory leak. -
Hi
You can try to new it so u can delete it after
drawing. Not sure why painter.drawImage should change anything.QImage *qtImg=new QImage ((const uchar *) pData, width, height, fmt); painter.drawImage(iHStep == 1 ? printerX : (printerX - width) xxx delete qtImg;
Also the pData use to create the Image, its deleted else where ? ( or dont need deletion)
-
Hi,
How many images are you painting ? Which size are they ?
-
this size is fixed for the printing.
I make 1000 * 1000 by default
The number of images depends on the size of paper and the DPI -
My goal is to be able to print on plotter (sorry google translate)
Printing on paper with large size (ex 1040mm * 3800mm) -
So basically you are drawing several tiles that are about 4MB each ?
-
I made a try:
store all QImages in list intead of calling drawImage and the memory usage is completely different. -
It's not the same use case
-
I compared my code with a MFC code. And the memory usage is totally different.
I will try another way:
Is it possible to print with vectorized data, i mean using HPGL to print my plan.
My goal is to be able to print dwg plan with scale 1:1.Thanks.
-
Hi
I would see if you could reuse the dwg reading code from
https://github.com/LibreCAD/LibreCAD
That would allow true vector output.