Skip to content

change Buffer to Uint8Array in fromRgbaPixels#41

Merged
Brooooooklyn merged 1 commit into
Brooooooklyn:mainfrom
KhafraDev:fromrgbapixels-uint8array
Feb 16, 2023
Merged

change Buffer to Uint8Array in fromRgbaPixels#41
Brooooooklyn merged 1 commit into
Brooooooklyn:mainfrom
KhafraDev:fromrgbapixels-uint8array

Conversation

@KhafraDev
Copy link
Copy Markdown
Contributor

@KhafraDev KhafraDev commented Feb 15, 2023

hi

this allows for the following (only needed for typescript):

import { Transformer } from './index.js'

const width = 256
const height = 256
const uint8 = new Uint8Array(width * height * 4)
const transformer = Transformer.fromRgbaPixels(uint8, width, height)

this creates an empty 256x256 image. I use it to overlay multiple images without having to resize/stretch/overlap each other

Buffer is still allowed too, since it's a subclass of Uint8Array

const buffer = Buffer.alloc(width * height * 4) // slower
const transformer = Transformer.fromRgbaPixels(buffer, width, height)

it was possible before but I needed to cast Uint8Array to Buffer for typescript to be happy

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 15, 2023

Someone is attempting to deploy a commit to a Personal Account owned by @Brooooooklyn on Vercel.

@Brooooooklyn first needs to authorize it.

@Brooooooklyn Brooooooklyn merged commit 0fa1f3c into Brooooooklyn:main Feb 16, 2023
@KhafraDev KhafraDev deleted the fromrgbapixels-uint8array branch February 16, 2023 14:43
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.

2 participants