Check-in [a594d9fb9a]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use a much faster means of exporting image data.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:a594d9fb9a3040339eb5b64c931859e0c63c5410
User & Date: stephanie.gawroriski 2019-06-16 04:29:44
Context
2019-06-16
04:40
P4 PBM is packed in binary and is not in pixel bits, so write the file correctly. check-in: 1ff2b8e880 user: stephanie.gawroriski tags: trunk
04:29
Use a much faster means of exporting image data. check-in: a594d9fb9a user: stephanie.gawroriski tags: trunk
04:25
Switch to P4 format instead of P1 (smaller). check-in: 664cecdadf user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to bldt/mids/txt-to-pbm/dev/shadowtail/txttopbm/Main.java.

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
..
94
95
96
97
98
99
100



101
102
103
104
105
106
107
...
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136


137
138
139
140
141
/**
 * This class is used to convert a text file to a PBM.
 *
 * @since 2019/06/15
 */
public class Main
{
	/** Output column limit for PBM. */
	public static final int PBM_COLUMNS =
		72;
	
	/**
	 * Main entry point.
	 *
	 * @param __args Arguments.
	 * @since 2019/06/15
	 */
	public static final void main(String... __args)
................................................................................
			// important to have an entire image because we can just pipe
			// this out!
			Image image = Image.createImage(iw, fh);
			Graphics g = image.getGraphics();
			
			// RGB pixel output for lines
			int[] rgb = new int[sa];



			
			// Used to keep track of the current column since PBM cannot exceed
			// 72 characters
			int col = 1;
			
			// Process each line!
			while (!lines.isEmpty())
................................................................................
				// Draw text in black
				g.setColor(0x000000);
				g.drawString(ln, 0, 0, Graphics.TOP | Graphics.LEFT);
				
				// Get RGB pixel data
				image.getRGB(rgb, 0, iw, 0, 0, iw, fh);
				
				// Go through pixels and export
				for (int i = 0; i < sa; i++)
				{
					// Just black or white
					int v = rgb[i];
					ps.print(((v & 0xFFFFFF) == 0) ? '1' : '0');
					
					// End column?
					if ((col++) == PBM_COLUMNS)
					{
						ps.print('\n');
						col = 1;
					}
				}


			}
		}
	}
}








<
<
<
<







 







>
>
>







 







|


|
|
|
|
<
<
|
<
<
<
<
>
>





28
29
30
31
32
33
34




35
36
37
38
39
40
41
..
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
...
115
116
117
118
119
120
121
122
123
124
125
126
127
128


129




130
131
132
133
134
135
136
/**
 * This class is used to convert a text file to a PBM.
 *
 * @since 2019/06/15
 */
public class Main
{




	/**
	 * Main entry point.
	 *
	 * @param __args Arguments.
	 * @since 2019/06/15
	 */
	public static final void main(String... __args)
................................................................................
			// important to have an entire image because we can just pipe
			// this out!
			Image image = Image.createImage(iw, fh);
			Graphics g = image.getGraphics();
			
			// RGB pixel output for lines
			int[] rgb = new int[sa];
			
			// Bulk byte data, for the fastest possible writing
			byte[] bulk = new byte[sa];
			
			// Used to keep track of the current column since PBM cannot exceed
			// 72 characters
			int col = 1;
			
			// Process each line!
			while (!lines.isEmpty())
................................................................................
				// Draw text in black
				g.setColor(0x000000);
				g.drawString(ln, 0, 0, Graphics.TOP | Graphics.LEFT);
				
				// Get RGB pixel data
				image.getRGB(rgb, 0, iw, 0, 0, iw, fh);
				
				// Go through pixels and export to bulk format
				for (int i = 0; i < sa; i++)
				{
					// Format bulk data
					int v = (rgb[i] & 0xFFFFFF);
					bulk[i] = (byte)('0' + (v & 1));
				}


				




				// Write all bytes at once
				ps.write(bulk);
			}
		}
	}
}