How to load a canvas from png image on server instead of stored RGB?

How to load a canvas from png image on server instead of stored RGB?

Hello,


My way to load canvas seems long, that is:


save 3 files with the pixel of the canvas R G B
that I open with JSON invocation

  1. $filename0="test1_r.txt"; 
  2. $handle1 = fopen($filename0, "r");
  3. $contents0 = fread($handle1, filesize($filename0));
  4. fclose($handle1);

  5. $filename0="test1_g.txt"; 
  6. $handle1 = fopen($filename0, "r");
  7. $contents1 = fread($handle1, filesize($filename0));
  8. fclose($handle1);
  9. $filename0="test1_b.txt"; 
  10. $handle1 = fopen($filename0, "r");
  11. $contents2 = fread($handle1, filesize($filename0));
  12. fclose($handle1);

  13. $function_name = $_GET['jsonp'];

  14. $p["paragraphes"]=array($contents0,$contents1,$contents2);

  15. echo "$function_name (\n";
  16. print json_encode($p);
  17. echo ");\n";
 and afterward in the JQUERY:

  1. var url0="http://www.thecacaocafe.com/select_image_jsonp_bulk.php?myimg=I0&jsonp=?"; 

  2. $.getJSON(urls[n], mycallback);
  3. var mycallback = function(data) {


  4. str_r = data.paragraphes[0].split("-");
  5. str_g = data.paragraphes[1].split("-");
  6. str_b = data.paragraphes[2].split("-");
  7. for(var i=0;i<str_r.length;i++) {
  8. pixout2[i*4  ] = str_r[i];
  9. pixout2[i*4 +1 ] = str_g[i];
  10. pixout2[i*4 +2 ] = str_b[i];
  11. pixout2[i*4 +3 ] = 255;
  12. }
  13. contextout2.putImageData(imgdout2, 0, 0);
It seems there is a solution to download data with AJAX or JSONP from images stored in png.

Do we have to decode the data to traduce it in RGBA?

Does some one know the solution to this, please?

Thanks  

David  ( @webtecgeek   www.thecacaocafe.com )