title: Some troubles with Graphics in CodenameOne on iOS
body: <p>In my project, there were some differences between work on Android and iOS. includeNativeBool is false. </p>
  
  <p>For Example:
  <img src="https://i.stack.imgur.com/Zzl3M.jpg" alt="enter image description here"></p>
  
  <p>Code for this:</p>
  
  <pre><code>@Override
  public void paint(Graphics g) {
      x = getX();
      y = getY();
      w = getWidth();
      h = getHeight();
      r1 = w/20;
      r2 = r1/2;
      d1 = r1*2;
      d2 = r2*2;
  
      // Fill background
      g.setColor(getStyle().getFgColor());
      g.fillRect(x, y, w, h);
  }
  
  public void FirstPart(Graphics g) {
      g.setColor(getStyle().getBgColor());
      // North-West
      g.fillArc(x-r1, y-r1, d1, d1, 270, 360);
      // North
      g.fillArc(x+w/2-r1, y-r1, d1, d1, 180, 360);
      // North-East
      g.fillArc(x+w-r1, y-r1, d1, d1, 90, 180);
  }
  
  public void MiddlePartBegin(Graphics g) {        
      g.setColor(getStyle().getBgColor());
      // North-West
      g.fillArc(x-r2, y-r2, d2, d2, 270, 360);
      // North-East
      g.fillArc(x+w-r2, y-r2, d2, d2, 90, 180);        
  } 
  
  public void MiddlePartEnd(Graphics g) {
      if (dash != null) {
          int c = w/iW + (w % iW &gt; 0 ? 1 : 0); // Ceil
          for (int i=0;i&lt;c;i++) {
              g.drawImage(dash, i*iW+x, y+h-1);
          }
      }
  
      g.setColor(getStyle().getBgColor());
      // South-West
      g.fillArc(x-r2, y+h-r2, d2, d2, 270, 360);
      // South-East
      g.fillArc(x+w-r2, y+h-r2, d2, d2, 270, 360);
  } 
  
  public void LastPart(Graphics g) {
      g.setColor(getStyle().getBgColor());
      // South-West
      g.fillArc(x-r1, y+h-r1, d1, d1, 270, 360);
      // South-East
      g.fillArc(x+w-r1, y+h-r1, d1, d1, 270, 360);
  }    
  </code></pre>
  
  <p>Or this:</p>
  
  <p><img src="https://i.stack.imgur.com/KE5Nj.jpg" alt="enter image description here"></p>
  
  <p>As Image I'm used the URLImage class. Here is my Adapter code:</p>
  
  <pre><code>public static final URLImage.ImageAdapter ToCircle = new URLImage.ImageAdapter() {
  
      int borderWidth = 6;
  
      public EncodedImage adaptImage(EncodedImage downloadedImage, EncodedImage placeholderImage) {
          Image originalImage;
  
          // Crop and resize
          int w = downloadedImage.getWidth();
          int h = downloadedImage.getHeight();
          if (w &gt; h) {
              originalImage = downloadedImage.subImage(
                  (w-h)/2, 0, 
                  h, h, 
                  true
              );
          } else {
              originalImage = downloadedImage.subImage(
                  0, (h-w)/2, 
                  w, w, 
                  true
              );
          }
  
  
          int pS = Math.min(placeholderImage.getHeight(), placeholderImage.getWidth());
          originalImage = originalImage.scaledHeight(pS);
  
  
          w = originalImage.getWidth();
          h = originalImage.getHeight();
          Log.p(Integer.toString(w)+";"+Integer.toString(h));
          Image finalImage = Image.createImage(w+2*borderWidth, h+2*borderWidth);
  
          Image maskedImage = originalImage.applyMask(
              createCircleMask(w,h)
          );
  
          Graphics g  = finalImage.getGraphics();
          g.setColor(0xff3d00);
          g.fillRect(
                  0, 0, 
                  finalImage.getWidth(), finalImage.getHeight() 
                 // 0, 360
          );
          g.drawImage(maskedImage, borderWidth, borderWidth);
  
          w = finalImage.getWidth();
          h = finalImage.getHeight();
  
          return EncodedImage.createFromImage(
              finalImage.applyMask(
                  createCircleMask(w,h)
              ),
              false
          );
      }
  
      public Object createCircleMask(int w, int h) {
          Image maskImage = Image.createImage(w, h);
          Graphics g = maskImage.getGraphics();
          g.setAntiAliased(true);
          g.setColor(0x000000);
          g.fillRect(0, 0, w, h);
          g.setColor(0xffffff);
          g.fillArc(0, 0, w, h, 0, 360);
          return maskImage.createMask();
      }
  
      public boolean isAsyncAdapter() {
          return false;
      }
  };
  </code></pre>
  
  <p>In the last trouble Images maybe don't resized to plasehoder Image size...</p>
  
  <p>Also I'm noticed that elements with transparency are displayed as  transparent with value 0xFF</p>