bmp

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2023 License: BSD-3-Clause Imports: 5 Imported by: 9 modules, 7 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

bmp

tests Go Reference Go Report Card codecov

Package bmp implements a BMP image decoder and encoder.

The BMP specification is at http://www.digicamsoft.com/bmp/bmp.html.

Supported BMP features

  • 1, 2, 4, 8, 16, 24 and 32 bits per pixel
  • Top-down images (read-only)
  • RLE compression for 4 and 8 BPP images (read-only)
  • RGB555 and RGB565 types for 16 BPP images (read-only)

Installation

Use go get:

go get github.com/sergeymakinen/go-bmp

Then import the package into your own code:

import "github.com/sergeymakinen/go-bmp"

Example

f, _ := os.Open("file.bmp")
img, _ := bmp.Decode(f)
for i := 10; i < 20; i++ {
    img.(draw.Image).Set(i, i, color.NRGBA{
        R: 255,
        G: 0,
        B: 0,
        A: 255,
    })
}
f.Truncate(0)
bmp.Encode(f, img)
f.Close()

License

BSD 3-Clause

Documentation

Overview

Package bmp implements a BMP image decoder and encoder.

The BMP specification is at http://www.digicamsoft.com/bmp/bmp.html.

Example
package main

import (
	"image/color"
	"image/draw"
	"os"

	"github.com/sergeymakinen/go-bmp"
)

func main() {
	f, _ := os.Open("file.bmp")
	img, _ := bmp.Decode(f)
	for i := 10; i < 20; i++ {
		img.(draw.Image).Set(i, i, color.NRGBA{
			R: 255,
			G: 0,
			B: 0,
			A: 255,
		})
	}
	f.Truncate(0)
	bmp.Encode(f, img)
	f.Close()
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(r io.Reader) (image.Image, error)

Decode reads a BMP image from r and returns it as an image.Image.

func DecodeConfig

func DecodeConfig(r io.Reader) (image.Config, error)

DecodeConfig returns the color model and dimensions of a BMP image without decoding the entire image.

func Encode

func Encode(w io.Writer, m image.Image) error

Encode writes the image m to w in BMP format.

Types

type FormatError

type FormatError string

FormatError reports that the input is not a valid BMP.

func (FormatError) Error

func (e FormatError) Error() string

type UnsupportedError

type UnsupportedError string

UnsupportedError reports that the input uses a valid but unimplemented BMP feature.

func (UnsupportedError) Error

func (e UnsupportedError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址