Reuse DzLayeredTexture or Delete Old Ones

I am using the DzLayeredTexture so that I can build a pixmap that is a combination of two images:

      surfaceImage = App.getImageMgr().createLayeredTexture( textureName );
      surfaceImage.beginEditing();
      try
      {
        surfaceImage.size = new Size(DEFAULT_RESOLUTION, DEFAULT_RESOLUTION);
        var sLayer = this.surfaceImage.createLayer('Surface1');
        sLayer.imageFile = surface1Filename;
        var sLayer = surfaceImage.createLayer('Surface2');
        sLayer.imageFile = surface2Filename;
      }
      finally
      {
        surfaceImage.endEditing();
      }
      mylabel.pixmap = surfaceImage.getPreviewPixmap(this.DEFAULT_RESOLUTION, this.DEFAULT_RESOLUTION);

This works perfectly.  However, because I am doing this often, I am filling up the temp directory with a bajillion PNG temp files.  It seems like Daz creates a temporary FILE for every createLayeredTexture call.  I would like to not do that.  I have tried to only call  App.getImageMgr().createLayeredTexture once (and save it for later), but it doesn't seem like you can hold onto the handle for the layered texture.  Things start blowing up saying SurfaceImage does not have a beginEditing function, etc.  Is there anything I can do or do I just have to live with hundreds of temp PNG files?

Thanks.

 

Comments

  • jag11jag11 Posts: 885

    Maybe you could remove the related surfaceImage.getTempFilename() before new editing.

  • Thank you for the suggestion.  At least for my code, the getTempFilename() was blank.  I tried using the getFilename() but all of that code is obviously heavily multithreaded.  I would get confirmation in the log about deleting the filename and then it would be saved again later.  There also appeared to be race conditions as I could get Daz Studio in a bad state doing this.  

    Oh well, I guess I will have to live with lots of temp files.

Sign In or Register to comment.