Skip to content

Issue #686 - Memory leak on toNativeImage#748

Open
vBoykoGit wants to merge 1 commit into
exyte:masterfrom
vBoykoGit:fix/686-To-native-image-memory-leak
Open

Issue #686 - Memory leak on toNativeImage#748
vBoykoGit wants to merge 1 commit into
exyte:masterfrom
vBoykoGit:fix/686-To-native-image-memory-leak

Conversation

@vBoykoGit

Copy link
Copy Markdown

No description provided.

@akhrameev-picsart akhrameev-picsart left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@VineFiner

Copy link
Copy Markdown

Hello, can you add a scale?

    func toNativeImage(size: Size, _ scale: CGFloat = UIScreen.main.scale, layout: ContentLayout = .of()) -> MImage {
        let renderer = RenderUtils.createNodeRenderer(self, view: nil)
        let rect = size.rect()

        MGraphicsBeginImageContextWithOptions(size.toCG(), false, scale)
        let ctx = MGraphicsGetCurrentContext()!
        ctx.clear(rect.toCG())

        let transform = LayoutHelper.calcTransform(self, layout, size)
        ctx.concatenate(transform.toCG())
        renderer.render(in: ctx, force: false, opacity: self.opacity)

        let img = MGraphicsGetImageFromCurrentImageContext()
        MGraphicsEndImageContext()
        return img!
    }

@hotbott hotbott mentioned this pull request Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants