<commit_before>/* This file is part of magic-sdk, an sdk for the open source programming language magic.
 *
 * Copyright (C) 2016 magic-lang
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */

use base

import RasterBgra, RasterMonochrome

CreateAlphaByteString: class {
	init: func
	makeAlphaString: static func (filename, name: String) -> String {
		image := RasterBgra open(filename)
		buf := image buffer as ByteBuffer
		imageArray := "["
		ip: Int*
		ipbuffer := ByteBuffer new(image size area)
		for (i in 0 .. (buf size / 4))
			ipbuffer pointer[i] = buf pointer[(i * 4) + 3]
		ip = ipbuffer pointer as Int*
		if (ipbuffer size > 3)
			imageArray = imageArray >> ip[0] toString()
		for (i in 1 .. ipbuffer size / 4) {
			intString := ip[i] toString()
			imageArray = imageArray >> "," >> (i % 32 == 0 ? "\n" : " ") >> intString
			intString free()
		}
		imageArray += "]"<commit_msg>Adapted CreateAlphaByteString to rgb.<commit_after>/* This file is part of magic-sdk, an sdk for the open source programming language magic.
 *
 * Copyright (C) 2016 magic-lang
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */

use base

import RasterRgba, RasterMonochrome

CreateAlphaByteString: class {
	init: func
	makeAlphaString: static func (filename, name: String) -> String {
		image := RasterRgba open(filename)
		buf := image buffer as ByteBuffer
		imageArray := "["
		ip: Int*
		ipbuffer := ByteBuffer new(image size area)
		for (i in 0 .. (buf size / 4))
			ipbuffer pointer[i] = buf pointer[(i * 4) + 3]
		ip = ipbuffer pointer as Int*
		if (ipbuffer size > 3)
			imageArray = imageArray >> ip[0] toString()
		for (i in 1 .. ipbuffer size / 4) {
			intString := ip[i] toString()
			imageArray = imageArray >> "," >> (i % 32 == 0 ? "\n" : " ") >> intString
			intString free()
		}
		imageArray += "]"
{'fraction_non_alphanumeric': 0.1218144750254842, 'fraction_numerical': 0.01529051987767584, 'mean_word_length': 3.3719376391982183, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5815494', 'n_tokens_mistral': 690, 'n_tokens_neox': 620, 'n_words': 239}