> On May 2, 2016, at 12:36 PM, Christian Schmitz 
> <[email protected]> wrote:
> 
> Okay. If you use Console apps, you may look into NSAutoReleasePoolMBS class.
> Make a new instance before doing something and than release it later. This 
> cleans up all the temp objects between.

heh, the console app of the same code before adding the auto release pool grew 
to 1.5 gigs of memory usage in just 10 minutes ;) 

Do I understand the usage of these autoreleasepool objects properly? Just 
adding one to the app doesn’t seem to do anything, I have to force the 
autoreleasepool to be released and then anything I’ve allocated will be 
released along with it. I followed some of the examples that just replaced the 
current one with a new one in the same variable but those crashed instantly 
upon trying to do that. It seems that you must set the container variable to 
nil first, to let it do what it needs to do, and then create a new one in the 
second step. You can’t just replace the one thats there with a new one. Is that 
the proper way to do that?

how often should I be replacing that. Right now it’s on a timer and releases it 
every 10 seconds, but i could release it at the end of each frame handler but 
that seems overkill, or should I release everything instantly when I’m done 
with it?


> 
>> I’ve hit a snag in doing an NSAffineTransformMBS in the console app. The 
>> code that worked fine in the Desktop app is just:
>> 
>> That works perfectly to do a vertical/horizontal flip on an image with very 
>> few processing microseconds on a desktop app, but it somehow prevents the 
>> rendering of the image when compiled into a console app.
> 
> For me this works:
> 
>  dim f as FolderItem = SpecialFolder.Desktop.Child("test.jpg")
>  dim c as new CIImageMBS(f)
> 
> 
>  dim myFlipFilter as new CIFilterAffineTransformMBS
>  myFlipFilter.SetDefaults
>  dim myflipAffine as new NSAffineTransformMBS(-1.0,0.0,0.0,-1.0,0.0,0.0)
>  myFlipFilter.inputTransform = myflipAffine
> 
>  myFlipFilter.inputImage = c
>  dim out as CIImageMBS = myFlipFilter.outputImage
> 
> 
>  dim n as NSImageMBS = out.RenderNSImage
>  dim t as string = n.TIFFRepresentation


Rendering to an NSimage does seem to work. But it’s also twice as slow as 
outputting a CGImage. When I moved the code from the desktop app into the 
console app I also changed how I was rendering it. I was using the 
renderToPicture which doesn’t exist in the console, so I settled upon using 
out.CreateCGImage which I can draw into the context and then get the bitmap of 
very quickly. The console seems to be a red herring here sorry, you can’t using 
the CreateCGImage at all with a negative number in the transform. This fails 
even on the desktop built. I assumed it was the change to console, but it isn’t.

  dim f as FolderItem = SpecialFolder.Desktop.Child("test.jpg")
  dim c as new CIImageMBS(f)
  
  
  dim myFlipFilter as new CIFilterAffineTransformMBS
  myFlipFilter.SetDefaults
  dim myflipAffine as new NSAffineTransformMBS(-1.0,0.0,0.0,-1.0,0.0,0.0)
  myFlipFilter.inputTransform = myflipAffine
  
  myFlipFilter.inputImage = c
  dim out as CIImageMBS = myFlipFilter.outputImage
  
  dim n as CGImageMBS = out.CreateCGImage
  dim t as string = n.JPEGData
  
  f = SpecialFolder.Desktop.Child("output.jpeg")
  dim b as BinaryStream = BinaryStream.Create(f, true)
  b.Write t

you can send negative numbers to any of the other constructor values, but not 
to those 2 positions if you want to be able to get a CGImage out of it as 
opposed to an NSImage. 


Thanks,
 James


James Sentman                       http://www.PlanetaryGear.org                
http://MacHomeAutomation.com




_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
[email protected]
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Reply via email to