kalan Posted November 2, 2011 Posted November 2, 2011 When writing a file type plugin there is scratchSurface in OnSave method. Can anyone tell me what it is and what's for? Quote
midora Posted November 2, 2011 Posted November 2, 2011 When writing a file type plugin there is scratchSurface in OnSave method. Can anyone tell me what it is and what's for? The scratchSurface is a pixel buffer in the size of the document. You may use this buffer to render input (the document). The application may save memory if you are using this buffer and not your own one. 1 Quote
Rick Brewster Posted November 3, 2011 Posted November 3, 2011 Yeah it's a pre-allocated buffer you can use for whatever. Memory allocations are a major source of failure/crashes, and therefore if you can avoid allocations it really helps. Since the "scratch surface" is already allocated, and since a buffer of the same size as the image is commonly needed for saving, it is provided to the FileType's OnSave() method. You can't depend on the contents of the scratch surface being initialized, or uninitialized, to any particular pattern. So if you need to clear it out before writing other stuff to it, you should do so. 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.