offline
- savan2

- Građanin
- Pridružio: 15 Jul 2009
- Poruke: 150
|
Napisano: 14 Dec 2014 13:32
Hvala, malo sam googlao i vidim da AND je totalno nemoguce vratiti u pocetno stanje
Dopuna: 15 Dec 2014 14:20
Ukratko, pokusao sam da napravim alatku koja ce da pretvori png sliku u format isti kao sto alat PNG2CSCC pretvara, ali posto nema nikakav sourc, nisam uspeo da napravim, pa sam pokusavao neke gluposti dok nisam nasao png12cscc koji to radi, onda sam sastavio ovih par alata koje sluze za sve one koji zele da promene font a i velicinu fonta na cwm recovery android telefona. Php scripte konvertuju format generisan sa png2cscc u android recovery kompatibilni format, zato cisto ako nekom zatreba ovo je potrebno:
make_font_png.php
<?php
header('Content-Type: image/png');
//##########################################################
//##########################################################
//########## ONLY THIS CHANGE FOR YOUR NEEDS !!! ###########
//##########################################################
//##########################################################
$block_w = 25;
$block_h = 42;
$font_size_in_block = 32;
$font = 'C:\WINDOWS\Fonts\lucon.ttf';
//##########################################################
//##########################################################
//##########################################################
//##########################################################
//##########################################################
/* !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ */
$text = array(' ', '!', '"', "#", '$', '%', '&', "'", '(', ')', '*', '+', ',', '-',
'.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';',
'<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e',
'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', ' ');
$number_of_chars = sizeof($text);
$out_block_w = $block_w * $number_of_chars;
$out_block_h = $block_h;
$out_im = imagecreatetruecolor($out_block_w, $out_block_h);
$out_white = imagecolorallocate($out_im, 255, 255, 255);
$out_grey = imagecolorallocate($out_im, 128, 128, 128);
$out_black = imagecolorallocate($out_im, 0, 0, 0);
imagefilledrectangle($out_im, 0, 0, $out_block_w, $out_block_h, $out_white);
for ($i=0; $i<$number_of_chars; $i++) {
$im = imagecreatetruecolor($block_w, $block_h);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, $block_w, $block_h, $white);
// image font_size 0 x y black font text
imagettftext($out_im, $font_size_in_block, 0, $block_w * $i, $font_size_in_block, $black, $font, $text[$i]);
}
//display out image
imagepng($out_im);
//save out image
imagepng($out_im, "out.png");
imagedestroy($out_im);
imagedestroy($im);
?>
make_cwm_header.php:
<?php
if (!file_exists("out.inl"))
die('You need inl file generated with png2cscc.exe in rgb8 format! Call these file out.inl');
echo '<pre>' . "\57\52\40\102\171\40\115\165\156\152\145\156\151\40\100\40\62\60\61\64\40\52\57\n\n";
$file = file_get_contents("out.inl");
$lines = explode("\n", $file);
$variable = array();
$datas = array();
foreach ($lines as $line) {
if (preg_match("/=\s*(\d+)\s*;/", $line, $temp)) {
$variable[] = $temp[1];
} elseif (strstr($line, "0x")) {
$line = preg_replace("/([,\s]*)/", "", $line);
$datas[] = str_split($line, 4);
}
}
/*
echo '#if 0
static const struct {
unsigned int width;
unsigned int height;
unsigned int bytes_per_pixel; // 2:RGB16, 3:RGB, 4:RGBA
unsigned char pixel_data[' . $variable[0] . ' * ' . $variable[1] . ' * ' . $variable[2] . ' + 1];
} gimp_image = {
' . $variable[0] . ', ' . $variable[1] . ', ' . $variable[2] . ',
"';
foreach ($datas as $data) {
if ($byte) {
echo "\n \"";
}
foreach($data as $byte) {
echo "\\" . decoct(hexdec($byte));
}
echo "\"";
}
echo ",
};
#endif
";
*/
$n = ($variable[0] * $variable[1]);
$x = array();
$x_skip = 0;
$m = 0;
$run_val = 0;
$run_count = 0;
for ($i=0; $i<count($datas); $i++) {
for ($j=0; $j<count($datas[$i]); $j++) {
$x[] = $datas[$i][$j];
}
}
printf("struct {\n");
printf(" unsigned width;\n");
printf(" unsigned height;\n");
printf(" unsigned cwidth;\n");
printf(" unsigned cheight;\n");
printf(" unsigned char rundata[];\n");
printf("} font = {\n");
printf(" .width = %d,\n .height = %d,\n .cwidth = %d,\n .cheight = %d,\n", $variable[0], $variable[1], $variable[0] / 96, $variable[1]);
printf(" .rundata = {\n");
$run_val = ""; //$run_val = (hexdec($x[0][0]) ? 0 : 1);
$run_count = 1;
$n -= 1;
$x_skip += $variable[2];
while ($n-- > 0) {
$val = (hexdec($x[$x_skip]) ? 0 : 255);
$x_skip += $variable[2];
if(($val == $run_val) && ($run_count < 127)) {
$run_count++;
} else {
printf("0x%02x,", $run_count | ($run_val ? 0x80 : 0x00));
$run_val = $val;
$run_count = 1;
$m += 5;
if($m >= 80) {
printf("\n");
$m = 0;
}
}
}
printf("0x%02x,", $run_count | ($run_val ? 0x80 : 0x00));
printf("\n0x00,");
printf("\n");
printf(" }\n};\n");
echo "</pre>"
?>
Nije nesto lepo ali radi posao.
|