Load only rendered image
-
Hell,
I am develloping a qml application. I use Qt 4.8.4, QtQuick 1.1 32bitsI have a huge scene but only part of it is actually displayed. we reache the 32bit extended memmory limit, our process is 3Gb .
There are many svg images which weigh is 1Gb in memmory (when replacing them by rectangle the process is only 2Gb).
Is their a way to detect from a Qml "Image" object is rendered? so I could load dynamically the image only when render is required?
-
It might be a better idea to render those SVGs into PNG and using that at runtime. This might not be possible - depending on your use case. This is also what the documentation recommends.
-
OK,
What would be the reason?
the Png rendering is more efficient than Svg?
does it take less space in memory?We are using the Svg because of the vectorial format which allow to resize without loss
-
[quote author="Sil20" date="1416996964"]the Png rendering is more efficient than Svg?[/quote]
Yes, massively. SVG parsing and rendering in Qt is very expensive and should be avoided as much as possible. Also, the QtSvg module does not support full SVG specification.
-
OK thancks.
is there a tool to batch convert SVG to PNG ?
Since our svg are size properly and I assume we should define a Dpi to render properly pngs... -
I guess Phatch can do the job. I use it for JPEGs, but it may have SVG support.
-
Actually I developed the following "MyImage.qml" which reallocate the rendering pixmap using a quality criteria.
Since in my project the rendering quality may be reduce precisely on the process which is overloaded this might do the job.But I am wondering if i am not using a bug :
- modifiing " sourceSize.width" => width is modified
- modifiing " "width" => "sourceSize.width" is not modified
Is there another way to reallocat the pixmap?
Am I using a bug/feature?@
Image {onStatusChanged: {recomputesmoothness();} //All SVG or other image files are rendered in a Pixmap which is allocated in memmory //The code above allow to render a lower resolution pixmap in the same area function recomputesmoothness() { if (status == Image.Ready) { //Reduce Pixmaresolution if(SDCN.operatingMode !== SdcnOperatingMode.Suivi) { return } //DPI factor is used (considered befere below max resolution var lDPIFacor=0.3 var lw=width var lh=height var lhwFacor=1.0 var lwTmp=0 var lhTmp=0 if(lDPIFacor !=1.0) { lhwFacor=lDPIFacor lwTmp=Math.floor( width*lhwFacor) lhTmp=Math.floor(height*lhwFacor) console.log("-----------------------DPI factor is used----------------------------------------------") console.log("Factor:",lhwFacor,"Width:",width,"SourceWidth:",sourceSize.width,"NewWidth:",lwTmp) console.log("Factor:",lhwFacor,"Height:",height,"SourceHeight:",sourceSize.height,"NewHeight:",lhTmp) console.log(".") } //"Reallocate" the Pixmap sourceSize.width=lwTmp sourceSize.height=lhTmp //Resize properly the image width=lw height=lh } }
}@