Skip to content
Brom Bresenham edited this page Apr 7, 2024 · 15 revisions

BMP.rogue

class BMP [singleton]

extends Object

class BMPBitField [compound]

Global Methods

Signature Return Type Description
create( bitmask:Int, left_shift_for_argb:Int ) BMPBitField

Properties

Name Type Description
bitmask Int
left_shift_for_argb Int

Methods

Signature Return Type Description
bit_count() Int
bit_shift() Int
description() String
operator<>( other:BMPBitField ) Int
operator==( other:BMPBitField ) Logical
print_to( buffer:PrintWriter )
reader( [next=null:BMPColorComponentReader] ) BMPColorComponentReader
to<<Object>>() Boxed<<BMPBitField>>
to<<String>>() String

class BMPColorComponentReader

extends Object

Properties

Name Type Description
bits Int
next BMPColorComponentReader
shift Int

Methods

Signature Return Type Description
init( bitfield:BMPBitField, [next=null:BMPColorComponentReader] )
init( bits:Int, shift:Int, [next=null:BMPColorComponentReader] )
read( reader:BitReader, [argb=0:Int] ) Int

class BMPDecoder

extends Object

Global Methods

Signature Return Type Description
decode( encoded_bytes:Byte[], [bitmap=null:Bitmap] ) Bitmap

class BMPReader

extends BitReader

Properties

Name Type Description
bit_buffer Int64
buffer_count Int
input Reader<<Byte>>
position Int

Methods

Signature Return Type Description
read_int24_lh() Int
read_int32_lh() Int
read_uint16_lh() Int

enum BMPVersion

Categories

Category Value Description
BITMAPCOREHEADER 12
OS22XBITMAPHEADER16 16
OS22XBITMAPHEADER64 64
BITMAPINFOHEADER 40
BITMAPV2INFOHEADER 52
BITMAPV3INFOHEADER 56
BITMAPV4HEADER 108
BITMAPV5HEADER 124

Global Properties

Name Type Description
categories BMPVersion[]

Global Methods

Signature Return Type Description
create( name:String ) BMPVersion
create( value:Int ) BMPVersion

Properties

Name Type Description
value Int

Methods

Signature Return Type Description
description() String
name() String
operator?() Logical
operator<>( other:BMPVersion ) Int
operator==( other:BMPVersion ) Logical
print_to( buffer:PrintWriter )
to<<Int>>() Int
to<<Object>>() Object
to<<String>>() String

CPR.rogue

class CPRCompressor

extends Object

Description

USAGE
  uses Codec/CPR
  local original_bytes = Byte
  local compressor = CPRCompressor()
  local compressed_bytes = compressor.compress( original_bytes )
  local percent_of_original = ((compressed_bytes.count*100.0)/original_bytes.count).format(".2")
  println "$% ($/$)" (percent_of_original,compressed_bytes.count,original_bytes.count)

Properties

Name Type Description
backlinks Int32[]
counts Byte[]
data Byte[]
literals Byte[]
max_jumps Int
max_length Int
most_recent Int32[]
next_32_bits Int32[]
offsets Byte[]
output_bytes Byte[]

Methods

Signature Return Type Description
init()
compress( data:Byte[] ) Byte[]
compress( data:String ) Byte[]
compress( file:File ) Byte[]
find_longest_prior_sequence( limit:Int32 ) (Int32,Int32)
find_next_repeat_sequence( i1:Int32 ) (Int32,Int32,Int32)
on_literal_sequence( i1:Int32, count:Int32 )
on_repeat_sequence( i1:Int32, i0:Int32, count:Int32 )
post_process( bytes:Byte[] ) Byte[]
post_process_counts( literals:Byte[] ) Byte[]
post_process_literals( counts:Byte[] ) Byte[]
post_process_offsets( offsets:Byte[] ) Byte[]
sequence_length( i1:Int32, i2:Int32 ) Int32
write_section( bytes:Byte[], writer:DataWriter )

class CPRDecompressor

extends Object

Description

USAGE
  uses Codec/CPR
  local decompressor = CPRDecompressor()
  local decompressed_bytes = decompressor.decompress( compressed_bytes )
  @trace decompressed_bytes == original_bytes

Methods

Signature Return Type Description
decompress( data:Byte[] ) Byte[]
decompress( file:File ) Byte[]
preprocess( bytes:Byte[] ) Byte[]
preprocess_counts( bytes:Byte[] ) Byte[]
preprocess_literals( bytes:Byte[] ) Byte[]
preprocess_offsets( bytes:Byte[] ) Byte[]
read_stored_bytes( reader:DataReader ) Byte[]

CRC32.rogue

class CRC32 [compound]

Description

USAGE
  uses Codec/CRC32

  local crc32 = CRC32(bytes) # faster

    OR

  local crc32 = CRC32()
  crc32.add( bytes ) # faster
    OR
  crc32.add( forEach in bytes ) # slower

  println crc32->Int32
  println crc32->String

Global Properties

Name Type Description
crc32_table Int32[]

Global Methods

Signature Return Type Description
create( [hash=0:Int32] ) CRC32
create( bytes:Byte[] ) CRC32

Properties

Name Type Description
hash Int32

Methods

Signature Return Type Description
add( byte:Int32 )
add( bytes:Byte[] )
description() String
operator==( other:CRC32 ) Logical
print_to( buffer:PrintWriter )
to<<Int32>>() Int32
to<<Object>>() Boxed<<CRC32>>
to<<String>>() String

Huffman.rogue

class HuffmanBuilder

extends Object

Properties

Name Type Description
byte_node_lookup HuffmanNode[]
data Int32[]
large_node_lookup [Int32:HuffmanNode]
literal_bits Int32
max_value Int32
min_value Int32
nodes HuffmanNode[]
root HuffmanNode

Methods

Signature Return Type Description
add( bytes:Byte[] )
add( bytes:Byte[], i1:Int32, count:Int32 )
add( value:Int32 )
add( values:Int32[] )
add( values:Int32[], i1:Int32, count:Int32 )
compression() Real
construct() HuffmanNode
deconstruct()
register( value:Int32, node:HuffmanNode ) Only necessary if you want to pass in an extended HuffmanNode to control reading and writing.
root() HuffmanNode
size() Int32
write( writer:BitWriter )

class HuffmanNode

extends Object

Properties

Name Type Description
bits Int32
count Int32
left HuffmanNode
pattern Int32
right HuffmanNode
value Int32

Methods

Signature Return Type Description
init( left:HuffmanNode, right:HuffmanNode )
init( reader:BitReader, value_bits:Int32, [pattern=0:Int32], [bits=0:Int32] )
init( value:Int32 )
assign_bit_patterns( [pattern=0:Int32], [bits=0:Int32] )
bit_size( literal_bits:Int32 ) Int64
collect_leaves( nodes:HuffmanNode[] )
read( reader:BitReader ) Int32
to<<String>>() String
write( writer:BitWriter )
write_definition( writer:BitWriter, literal_bits:Int32 )

class HuffmanReader

extends Object

incorporates Reader<<$DataType>>

Description

General-purpose Huffman decoder. Reads a byte stream and decompresses values on the fly.

EXAMPLE
  uses Codec/Huffman

  local compressed = Byte[][...] # compressed data from HuffmanReader example

  local reader = HuffmanReader( compressed )
  local n = reader.read
  local a = reader.read_string( n )
  local b = reader.read_string( reader.read )
  @trace a
  # "This is the first test string."
  @trace b
  # "This is the second test string."

Properties

Name Type Description
literal_bits Int32
next Int32?
position Int
reader BitReader
remaining Int32
root HuffmanNode

Methods

Signature Return Type Description
init( bytes:Byte[] )
init( bytes:Byte[], i1:Int32, count:Int32 )
init( file:File )
init( reader:BitReader )
close()
has_another() Logical
on_end_use()
on_use() HuffmanReader
peek() Int32
position() Int
queue_next()
read() Int32
read_another() Int32?
read_definition()
read( buffer:Int32[], limit:Int ) Int
read( bytes:Byte[], [max=0:Int32] ) Byte[]
read( file:File ) Read values and store them into the given file
read_bytes( [max=0:Int32] ) Byte[]
read_string( [max=0:Int32] ) String
reset()
seek( pos:Int )
skip( n:Int )
to<<Int32[]>>() Int32[]
to<<String>>() String

class HuffmanWriter

extends Object

incorporates Writer<<$DataType>>

Description

General-purpose Huffman encoder to compress Int32 values of any range, encoding on the fly.

EXAMPLE
  uses Codec/Huffman

  local writer = HuffmanWriter()
  local st1 = "This is the first test string."
  local st2 = "This is the second test string."
  writer.write( st1.count )
  writer.write( st1 )
  writer.write( st2.count )
  writer.write( st2.to_utf8 )
  writer.flush

  local compressed = writer.output_bytes
  println "$ compressed bytes vs $ original string characters" ...
      (compressed.count,st1.count+st2.count)
  # 50 compressed bytes vs 61 original string characters

Properties

Name Type Description
buffer Int32[]
builder HuffmanBuilder
granularity Int The proportions of most-frequent and least-frequent bytes can change over the course of a dataset so HuffmanWriter buffers values and checks every 'granularity' number of values for a worsening compression ratio and writes out the buffer using the best chunk size. 'granularity' is automatically adjusted by write(Byte[]) and write(Int32[]) to be 1/256th of the total data size.

In other words, if granularity is set to 1024 then the compression ratio will be evaluated at buffer sizes 1024, 2048, 3072, etc. If the compression ratio improves for 2048 and 3072 but gets worse for 4096, 3072 values will be written out and a new Huffman Tree will be created with the remaining 1024 bytes.
output_bytes Byte[]
position Int
prev_compression Real
writer BitWriter

Methods

Signature Return Type Description
init()
init( file:File )
init( output_bytes:Byte[] )
init( writer:BitWriter )
init( writer:Writer<<Byte>> )
adjust_granularity( total_count:Int32 ) Optional
close()
flush()
on_cleanup()
on_use() HuffmanWriter
on_end_use( err:Exception ) Exception
position() Int
reset()
seek_end()
seek( pos:Int )
skip( n:Int )
write_buffered_chunk()
write( bytes:Byte[] )
write( file:File )
write( value:Int32 )
write( value:String )
write( values:Int32[] )

JPEG.rogue

class JPEGDecoder

extends Object

Properties

Name Type Description
encoded_bytes Byte[]
error_handler JPEGErrorHandler
image_height Int32
image_width Int32

Methods

Signature Return Type Description
decode( encoded_bytes:Byte[], [dest_bitmap=null:Bitmap], &make_power_of_two ) Bitmap
image_size() IntXY

class JPEGEncoder

extends Object

Properties

Name Type Description
error_handler JPEGErrorHandler

Methods

Signature Return Type Description
encode( bitmap:Bitmap, [encoded_bytes=null:Byte[]], [quality=75:Int32] ) Byte[]

class JPEGErrorHandler [compound]

Methods

Signature Return Type Description
description() String
operator==( other:JPEGErrorHandler ) Logical
print_to( buffer:PrintWriter )
to<<Object>>() Boxed<<JPEGErrorHandler>>
to<<String>>() String

JSON.rogue

class JSON

extends Object

Global Methods

Signature Return Type Description
load( file:File, [error_log=null:PrintWriter] ) Variant
parse( file:File, [error_log=null:PrintWriter] ) Variant
parse( json:String, [error_log=null:PrintWriter] ) Variant
save( value:Variant, file:File, [formatted=false:Logical], [omit_commas=false:Logical] ) Logical

class JSONParseError

extends Error

Properties

Name Type Description
message String
stack_trace StackTrace

Methods

Signature Return Type Description
init( message:String )

class JSONParser

extends Object

Properties

Name Type Description
reader Scanner

Methods

Signature Return Type Description
init( file:File )
init( json:String )
init( reader:Scanner )
consume_spaces()
consume_whitespace()
consume_whitespace_and_eols()
consume( ch:Character ) Logical
has_another() Logical
next_is_identifier() Logical
next_is( ch:Character ) Logical
parse_hex_quad() Character
parse_identifier() String
parse_number() Variant
parse_string() String
parse_value() Variant
parse_list( [open_ch='[':Character], [close_ch=']':Character] ) Variant
parse_table( [open_ch='{':Character], [close_ch='}':Character] ) Variant
peek() Character
read() Character

PNG.rogue

class PNGDecoder

extends Object

Properties

Name Type Description
image_height Int32
image_width Int32
reader ListReader<<Byte>>

Methods

Signature Return Type Description
decode( encoded_bytes:Byte[], &make_power_of_two ) Bitmap
image_size() IntXY

class PNGEncoder

extends Object

Properties

Name Type Description
encoded_bytes Byte[]

Methods

Signature Return Type Description
encode( bitmap:Bitmap, [encoded_bytes=null:Byte[]] ) Byte[]

SHA.rogue

class SHA [singleton]

extends Object

Description

EXAMPLE USAGE
  uses Codec/SHA

  println SHA.sha256( "" )
    # E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855

  println SHA.sha256( "hello world" )
    # B94D27B9934D3E08A52E52D7DA7DABFAC484EFE37A5380EE9088F7ACE2EFCDE9

  println SHA.sha256( Byte[][...] )
  println SHA.sha256( File(...) )

Properties

Name Type Description
k Int[] Round constants (first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)

Methods

Signature Return Type Description
sha256( bytes:Byte[] ) String
sha256( data_reader:Reader<<Byte>>, byte_count:Int32 ) String Note 1: All variables are 32 bit unsigned integers and addition is calculated modulo 232 Note 2: For each round, there is one round constant k[i] and one entry in the message
        schedule array w[i], 0 ≤ i ≤ 63
Note 3: The compression function uses 8 working variables, a through h Note 4: Big-endian convention is used when expressing the constants in this pseudocode,
        and when parsing message block data from bytes to words, for example,
        the first word of the input message "abc" after padding is 0x61626380
sha256( file:File ) String
sha256( st:String ) String

class SHA256DataReader

extends Object

incorporates Reader<<$DataType>>

Properties

Name Type Description
byte_position Int32
bytes_remaining Int32
data Reader<<Byte>>
data_count Int32
next_result Int32?
padding Byte[]
position Int

Methods

Signature Return Type Description
init( data:Byte[] )
init( data:Reader<<Byte>>, data_count:Int32 ) Pre-processing (Padding) begin with the original message of length L bits append a single '1' bit append K '0' bits, where K is the minimum number >= 0 such that L + 1 + K + 64 is a multiple of 512 append L as a 64-bit big-endian integer, making the total post-processed length a multiple of 512 bits such that the bits in the message are [L data bits, 1, K zero bits, L in 64 bits] = k*512 total bits
close()
has_another() Logical
on_end_use()
on_use() SHA256DataReader
peek() Int32
position() Int
prepare_next_result()
read() Int32
read_byte() Int32
read( buffer:Int32[], limit:Int ) Int
reset()
seek( pos:Int )
skip( n:Int )
to<<Int32[]>>() Int32[]
to<<String>>() String

UTF16String.rogue

class UTF16String

extends Object

incorporates Poolable

Properties

Name Type Description
data Byte[]

Methods

Signature Return Type Description
init()
init( text:String )
init( utf16_bytes:Byte[] )
init( wchar_data:RogueWordPointer )
on_return_to_pool()
to<<String>>() String

ValueCompressor.rogue

class ValueIDLookupTable

extends Object

Properties

Name Type Description
id_list Variant

Methods

Signature Return Type Description
init( info:Variant )
get( index_string:String ) Variant

class ValueIDTableBuilder

extends Object

Properties

Name Type Description
id_list Variant
id_table Variant

Methods

Signature Return Type Description
get( value:Variant ) Variant

WAV.rogue

class WAV

extends Object

Properties

Name Type Description
bit_depth Int32
channels WAVChannel[]
error String
format WAVFormat
page_align Logical
sample_rate Int32

Methods

Signature Return Type Description
init( file:File )
init( format:WAVFormat, bit_depth:Int32, sample_rate:Int32 )
create_channel() WAVChannel
save( file:File ) Logical
to<<String>>() String
validate() Logical

class WAVChannel

extends Object

Properties

Name Type Description
samples Real32[]
wav WAV

Methods

Signature Return Type Description
init( wav:WAV )
add( sample:Real )
count() Int32
get( index:Int32 ) Real
read( reader:DataReader )
write( index:Int32, writer:DataWriter )

class WAVDecoder [singleton]

extends Object

Description

http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html http://tiny.systems/software/soundProgrammer/WavFormatDocs.pdf

Properties

Name Type Description
reader DataReader
wav WAV

Methods

Signature Return Type Description
decode( reader:DataReader, wav:WAV ) Logical
id_to_string( id:Int32 ) String
read_another_chunk()

class WAVEncoder [singleton]

extends Object

Methods

Signature Return Type Description
encode( wav:WAV ) Byte[]
encoded_size( wav:WAV ) Int32

enum WAVFormat

Categories

Category Value Description
PCM 1
IEEE_FLOAT 3
ALAW 6 8-bit ITU-T G.711 A-law
MULAW 7 8-bit ITU-T G.711 µ-law
EXTENSIBLE 65534 Determined by SubFormat

Global Properties

Name Type Description
categories WAVFormat[]

Global Methods

Signature Return Type Description
create( name:String ) WAVFormat
create( value:Int ) WAVFormat

Properties

Name Type Description
value Int

Methods

Signature Return Type Description
description() String
exists() Logical
name() String
operator?() Logical
operator==( other:WAVFormat ) Logical
print_to( buffer:PrintWriter )
to<<Int>>() Int
to<<Object>>() Object
to<<String>>() String

XML.rogue

class XML

extends Object

Global Properties

Name Type Description
next_column Int
next_filepath String
next_line Int

Global Methods

Signature Return Type Description
create( content:String, [line=1:Int], [column=1:Int] ) XML
create( file:File, [line=1:Int], [column=1:Int] ) XML
create( filepath:String, content:String, [line=1:Int], [column=1:Int] ) XML
element( [name=null:String] ) XML
list() XML
set_position( filepath:String, line:Int, column:Int )
text( text:String ) XML

Properties

Name Type Description
attributes [String:String]
children XML[]
column Int
filepath String
line Int
text String
type XMLNodeType

Methods

Signature Return Type Description
init( type:XMLNodeType, [text=null:String] )
add( child:XML )
content() String 'children' returns a list of XML nodes but 'content' returns them in string form
count() Int
find( fn:Function(XML)->Logical ) XML
get( index:Int ) XML
get( name:String ) String
insert( child:XML, [before_index=0:Int] )
is_list() Logical
is_text() Logical
is_element( [name=null:String] ) Logical
is_end_tag( [name=null:String] ) Logical
is_start_tag( [name=null:String] ) Logical
name() String
set( name:String, value:String )
to<<String>>() String
to<<String>>( &formatted ) String
write( builder:String, &formatted ) String

enum XMLNodeType

Categories

Category Value Description
ELEMENT 0 has a name and possibly attributes and child nodes
LIST 1 unnamed element with no attributes, just children
TEXT 2 a text node with no attributes or children
START_TAG 3 intermediate type
END_TAG 4 intermediate type

Global Properties

Name Type Description
categories XMLNodeType[]

Global Methods

Signature Return Type Description
create( name:String ) XMLNodeType
create( value:Int ) XMLNodeType

Properties

Name Type Description
value Int

Methods

Signature Return Type Description
description() String
name() String
operator?() Logical
operator==( other:XMLNodeType ) Logical
print_to( buffer:PrintWriter )
to<<Int>>() Int
to<<Object>>() Object
to<<String>>() String

class XMLNodifier

extends Object

Properties

Name Type Description
nodes XML[]
preformatted Int
scanner XMLScanner

Methods

Signature Return Type Description
init()
consume_whitespace( builder:String )
discard_comment()
nodify_another() Logical
nodify( file:File, [line=1:Int], [column=1:Int] ) XML[]
nodify( filepath:String, content:String, [line=1:Int], [column=1:Int] ) XML[]
tokenize_end_tag()
tokenize_tag()
tokenize_text()

class XMLParser

extends Object

Global Properties

Name Type Description
default_standalone_tags String[]

Properties

Name Type Description
standalone_tags [String:String]

Methods

Signature Return Type Description
init()
add_standalone_tag( name:String ) name example: image
collapse_nodes( nodes:XML[] )
configure_standalone_tags()
parse( file:File, [line=1:Int], [column=1:Int] ) XML
parse( filepath:String, content:String, [line=1:Int], [column=1:Int] ) XML

class XMLScanner

extends Scanner

Properties

Name Type Description
column Int
count Int
data Character[]
filepath String
line Int
position Int
source String
spaces_per_tab Int

Methods

Signature Return Type Description
init( filepath:String, content:String, [line=1:Int], [column=1:Int] )
consume_whitespace() Logical
consume_end_tag( name:String ) Logical
next_is_end_tag( name:String ) Logical
scan_lowercase_id() String

Zip.rogue

class Zip

extends Object

Description

NOTES
  Uses kuba-- zip 0.2.4
  https://github.com/kuba--/zip

Properties

Name Type Description
compression Int32 0 (uncompressed) to 9 (maximum compression)
filepath String
mode Int32 CLOSED, READ, WRITE, APPEND, DELETE (can change frequently internally)

Methods

Signature Return Type Description
init( zipfile:File, [compression=Zip.COMPRESSION_DEFAULT:Int32] )
add( archive_filepath:String, data:Byte[], [compression=null:Int32?], &verbose )
add( archive_filepath:String, data:String, [compression=null:Int32?], &verbose )
add( archive_filepath:String, file:File, [compression=null:Int32?], &verbose )
add( file:File, [compression=null:Int32?], &ignore_hidden=true, &verbose )
add( files:Files, [compression=null:Int32?], &ignore_hidden=true, &verbose )
close()
count() Int32
extract( folder:File, &verbose )
find( name:String ) ZipEntry[]
find( pattern:FilePattern ) ZipEntry[] Examples:
  zip.find( "ExactName.txt" ) -> result count 0 or 1
  zip.find( "*.txt" ) -> result count 0+
get( index:Int32 ) ZipEntry
on_cleanup()
open( zipfile:File, [compression=Zip.COMPRESSION_DEFAULT:Int32], [new_mode=Zip.CLOSED:Int32] )
remove( list:ZipEntry[] )
remove( name:String )
remove( pattern:FilePattern )
set_compression( new_compression:Int32 )
set_mode( new_mode:Int32 )
to<<String>>() String

class ZipEntry [compound]

Global Properties

Name Type Description
buffer Byte[]

Global Methods

Signature Return Type Description
create( zip:Zip, name:String, is_folder:Logical, size:Int64, crc32:Int32 ) ZipEntry

Properties

Name Type Description
crc32 Int32
is_folder Logical
name String
size Int64
zip Zip

Methods

Signature Return Type Description
description() String
extract_bytes() Byte[]
extract_string() String
extract( buffer:Byte[] ) Byte[]
extract( file:File )
operator==( other:ZipEntry ) Logical
print_to( buffer:PrintWriter )
to<<Object>>() Boxed<<ZipEntry>>
to<<String>>() String
Clone this wiki locally