Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

indie-raster

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

indie-raster

  • 0.0.10
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

indie-raster

...is a small raster graphics library.

  • (platform-independent C program) + wrappers
  • no dependencies — not even for drawing text!

Features

  • draw images
  • draw UPC barcodes
  • draw text via pre-rendered fonts

Limitations

  • Only black and white so far. Grayscale and color support should be pretty easy to add.

Pre-rendered fonts

PRF1 is a trivial file format indie-raster made up for pre-rendered fonts. See docs/PRF1.md

Ruby Wrapper

require 'indie-raster'

s = IndieRasterSession.new

HEADER = 10
FOOTER = 11
BIG_FONT = 20
s.loadImage :id => HEADER, :path => "images/header.pbm"
s.loadImage :id => FOOTER, :data => footer_pbm_bytes
s.loadFont :id => BIG_FONT, :path => "fonts/dsm-24.prf1"

s.createBlank :id => 1, :w => 576, :h => 1000

s.drawImage :id => HEADER, :x => 100, :y => 100, :on => 1
s.drawImage :id => FOOTER, :x => 100, :y => 900
# (:on defaults to 1)

s.drawText :text => "Taxi:", :font => BIG_FONT, :x => 20,         :y => 200
s.drawText :text => "1729",  :font => BIG_FONT, :toLeftOf => 560, :y => 200

s.drawUPC :upc => "123456123456", :x => 10, :y => 500, :w => 475, :h => 70

result_pbm = s.exportP4

C program

cat commands | indie-raster > result.pbm

Example Commands File

createBlank   1 576 1000
drawBarcode   1 10 200 123456123456 475 70 10 0 0
exportP4      1

Example 2

# if a line is blank or starts with "#", it is ignored
# line ending: \n
#-----------------------------------------------------------
#             (dest id)       (w)        (h)
createBlank       1           576       1000
#-----------------------------------------------------------
#             (dest id)    (num bytes)
loadImage         2            1729
...raw image bytes...
#-----------------------------------------------------------
#             (dest id)    (num bytes)
loadFont          3            3176
...PRF1 bytes...
#-----------------------------------------------------------
#             (dest id)   (x)  (y)    (src id)
drawImage         1        0    0         2
#-----------------------------------------------------------
#             (dest id)   (x)  (y)    (font id)   (num chars)
drawText          1        10   100       3           5
..."¿123?", UTF-32-little-endian-encoded...
# (bytes: BF 00 00 00 31 00 00 00 32 00 00 00 33 00 00 00 3F 00 00 00)
#-----------------------------------------------------------
#             (dest id)   (x)  (y)  (12-digit string) (w)  (h)   (guard bar extra h)  (middle font)  (side font)
drawBarcode       1        10   200   123456123456    475   70             0                0             0
# (a font ID of 0 means no text)
#-----------------------------------------------------------
#             (src id)
exportP4          1
#-----------------------------------------------------------

FAQs

Package last updated on 12 May 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc