Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add writePixels() utility to astrotiff module in @observerly/iris #227

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions pkg/astrotiff/writer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*****************************************************************************************************************/

// @author Michael Roberts <[email protected]>
// @package @observerly/iris/astrotiff
// @license Copyright © 2021-2024 observerly

/*****************************************************************************************************************/

package astrotiff

/*****************************************************************************************************************/

import (
"io"
)

/*****************************************************************************************************************/

// writePixels writes the internal byte array of an image to w. It is less general
// but much faster then encode. writePixels is used when pix directly
// corresponds to one of the TIFF image types.
func writePixels(w io.Writer, pix []byte, nrows, length, stride int) error {
if length == stride {
_, err := w.Write(pix[:nrows*length])
return err
}

for ; nrows > 0; nrows-- {
if _, err := w.Write(pix[:length]); err != nil {
return err
}
pix = pix[stride:]
}

return nil
}

/*****************************************************************************************************************/
Loading