2009-02-09 21:57:26 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! Copyright (C) 2007, 2009 Doug Coleman.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! See http://factorcode.org/license.txt for BSD license.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								USING: accessors alien alien.c-types arrays byte-arrays columns
							 | 
						
					
						
							
								
									
										
										
										
											2009-06-03 00:29:04 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								combinators compression.run-length endian fry grouping images
							 | 
						
					
						
							
								
									
										
										
										
											2009-06-11 14:16:04 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								images.bitmap.loading images.loader io
							 | 
						
					
						
							
								
									
										
										
										
											2009-06-09 11:50:21 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								io.encodings.string io.files io.streams.limited kernel locals
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								macros math math.bitwise math.functions namespaces sequences
							 | 
						
					
						
							
								
									
										
										
										
											2009-06-06 21:10:40 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								specialized-arrays.uint specialized-arrays.ushort strings
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								summary ;
							 | 
						
					
						
							
								
									
										
										
										
											2009-06-03 22:36:03 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								QUALIFIED-WITH: bitstreams b
							 | 
						
					
						
							
								
									
										
										
										
											2009-02-09 21:57:26 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								IN: images.bitmap
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-06-11 14:16:04 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: write2 ( n -- ) 2 >le write ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: write4 ( n -- ) 4 >le write ;
							 | 
						
					
						
							
								
									
										
										
										
											2009-06-03 22:36:03 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 15:48:28 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: save-bitmap ( image path -- )
							 | 
						
					
						
							
								
									
										
										
										
											2009-02-09 21:57:26 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    binary [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        B{ CHAR: B CHAR: M } write
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        [
							 | 
						
					
						
							
								
									
										
										
										
											2009-06-09 11:50:21 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            bitmap>> length 14 + 40 + write4
							 | 
						
					
						
							
								
									
										
										
										
											2009-02-09 21:57:26 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            0 write4
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            54 write4
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            40 write4
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        ] [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            {
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 16:08:50 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                ! width height
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 15:48:28 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                [ dim>> first2 [ write4 ] bi@ ]
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 16:08:50 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                ! planes
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 15:48:28 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                [ drop 1 write2 ]
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 16:08:50 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                ! bit-count
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 15:48:28 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                [ drop 24 write2 ]
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 16:08:50 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                ! compression
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 15:48:28 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                [ drop 0 write4 ]
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 16:08:50 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-06-06 21:10:40 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                ! image-size
							 | 
						
					
						
							
								
									
										
										
										
											2009-06-09 11:50:21 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                [ bitmap>> length write4 ]
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 16:08:50 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                ! x-pels
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 15:48:28 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                [ drop 0 write4 ]
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 16:08:50 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                ! y-pels
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 15:48:28 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                [ drop 0 write4 ]
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 16:08:50 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                ! color-used
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 15:48:28 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                [ drop 0 write4 ]
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 16:08:50 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                ! color-important
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 15:48:28 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                [ drop 0 write4 ]
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-14 16:08:50 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-06-03 00:20:07 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                ! color-palette
							 | 
						
					
						
							
								
									
										
										
										
											2009-06-09 11:50:21 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                [ bitmap>> write ]
							 | 
						
					
						
							
								
									
										
										
										
											2009-02-09 21:57:26 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            } cleave
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        ] bi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ] with-file-writer ;
							 |