Dark-Show

Digole OLED12864 PNG2BIN (Start Screen Format)

May 15th, 2014
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. <?php
  2.  
  3. //*************************************************
  4. //Digole OLED12864 PNG2BIN
  5. //Programmer: Gregory Michalik
  6. //Email: gregory954(a)gmail.com
  7. //**************************************************
  8. //Takes IMG.png and outputs output.bin to be sent to
  9. //the OLED12864 as the start screen.
  10. //("SSS",0x00,0x04,Sendfile(output.bin))
  11. //IMG.png must be 128x64 and Black/White.
  12. //**************************************************
  13.  
  14. $im = imagecreatefrompng("IMG.png");
  15. $a=fopen("output.bin","w");
  16. for($y=0;$y<64;$y=$y+8){
  17. for($x=0;$x<128;$x++){
  18. $data="";
  19. for($y2=$y;$y2<$y+8;$y2++){if(imagecolorat($im,$x,$y2)==0){$data.="0";}else{$data.="1";}}
  20. fputs($a,pack('H*', str_pad(base_convert($data, 2, 16), 2, "0", STR_PAD_LEFT)));
  21. }}
  22. fclose($a);
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment