Javascript canvas memory issue in Firefox -
I am trying to resize an image in several steps to increase the quality of the final image. This Opera works fine in the browser, but I think Firefox has a memory problem. After resizing some images, the following error has been made: Error: Image is corrupted or small: Blob: [XY]. So my question: Do you see a memory problem in the following code?
loadImage.halfSize = function (i) {var c = document.createElement ("canvas"); C. With it Wide / 2; C. Hight = I Height / 2; Var ctx = c.getContext ("2D"); Ctx.drawImage (i, 0, 0, c.width, c.height); Return c; }; LoadImage.renderImageToCanvas = Function (Canvas, IMG, Sourcex, Source, SourceWidth, SourceHight, Destix, DSTI, DISTVUTH, DEST HEAT) {Canvas.Wind = SourceView; Canvas.height = sourceHeight; Canvas.getContext ('2d'). DrawImage (IMG, Source X, Source, SourceWith, SourceHight); If (SourceViews & lt; = destWidth & Source Hight & lt; = destHeight) {Return Canvas; } While (canvas.wind> dwindvooth * 2) {canvas = loadmege. Half size (canvas); } Var Canvas = Document. CreateElement ("Canvas"); CanvasRes.width = destWidth; Canvas Race Heights = devastated; Var canvasRSCTX = canvasRes.GetConttex ("2D"); CanvasResCtx.drawImage (canvas, 0, 0, canvasas wide, canvas ras.); Return canvasiris; };
I do not see a leak because I am using local variables everywhere, so the memory of the canvas-elements created after each call (half the size) Should free?
Thank you for your help! Ben
Comments
Post a Comment