SVG Loader problem

  ... the SVG Extension for AndEngine.

SVG Loader problem

Postby angel.ivorra » Sat Dec 17, 2011 1:37 pm

I'm using this extension for a while.

I try to render a svg to file to match the background and make a paralexBackground. The problem is that the render of the svg file is not pixel perfect. I'll explain.

I have this svg file, a blue square.

I render the file like that:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                 final PictureBitmapTextureAtlasSource textureSource = new SVGAssetBitmapTextureAtlasSource(
  2.                                 aBase, source_svg_file, width, height);
  3.                 Bitmap pBitmap = null;
  4.  
  5.  
  6.                 try {
  7.                         pBitmap = textureSource.onLoadBitmap(Config.ARGB_8888);
  8.                 } catch (Exception e) {
  9.                         e.printStackTrace();
  10.                         Log.d(TAG, e.getMessage());
  11.                 }
  12.  
  13.               //Here i plan to cut that line of pixels...
  14.  
  15.                 try {
  16.                         FileOutputStream out = new FileOutputStream(output_png_file);
  17.  
  18.                         pBitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
  19.                 } catch (Exception e) {
  20.                         e.printStackTrace();
  21.                 }
  22.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


And the result is a blue square, but in the last pixel of the right side, there is a line with transparent pixels... can i avoid that??

fondo01_abajo2.png
fondo01_abajo2.png (1.02 KiB) Viewed 778 times


I'm thinking in some post-process the png to cut that last pixels.... but i prefer a clean solution....

Can anyone help me, please?


Thank you all.
angel.ivorra
 
Posts: 37
Joined: Mon Mar 21, 2011 11:49 pm

Re: SVG Loader problem

Postby angel.ivorra » Sat Dec 17, 2011 2:22 pm

I have solved it :

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. final PictureBitmapTextureAtlasSource textureSource = new SVGAssetBitmapTextureAtlasSource(
  2.                                 aBase, fichero_origen, ancho+1, alto+1);
  3.                 Bitmap pBitmap = null;
  4.                 try {
  5.                         pBitmap = textureSource.onLoadBitmap(Config.ARGB_8888);
  6.                         Log.d(TAG, "Width :" + pBitmap.getWidth() + " Height :"+pBitmap.getHeight());
  7.                 } catch (Exception e) {
  8.                         e.printStackTrace();
  9.                         Log.d(TAG, e.getMessage());
  10.                 }
  11.                
  12.                 Bitmap pBmp = null;
  13.                 try
  14.                 {
  15.                                 pBmp = Bitmap.createBitmap(pBitmap, 0, 0, ancho, alto);
  16.                 }
  17.                  catch (Exception e)
  18.                  {
  19.                          Log.d(TAG,e.getMessage());
  20.                          e.printStackTrace();
  21.                  }
  22.  
  23.                 Log.d(TAG, "Grabamos a fichero");
  24.                 try {
  25.                         FileOutputStream out = new FileOutputStream(fichero_destino);
  26.                         pBmp.compress(Bitmap.CompressFormat.PNG, 100, out);
  27.                 } catch (Exception e) {
  28.                         e.printStackTrace();
  29.                 }
  30.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


But i would like a cleaner way to solve this... If anyone has suffered the same problem, please tell me...
angel.ivorra
 
Posts: 37
Joined: Mon Mar 21, 2011 11:49 pm


Return to SVG

Who is online

Users browsing this forum: No registered users and 1 guest