Example #1
0
  private void resetSelectedDrawerItem(TableRow tr, TextView tv) {
    if (tr != null && tv != null) {
      tr.setBackgroundColor(Color.parseColor(getResources().getString(R.color.color_white)));
      tv.setTextColor(Color.parseColor(getResources().getString(R.color.list_text_color)));
      switch (tv.getId()) {
        case R.id.tv_apply:
          tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.apply_icon, 0, 0, 0);
          break;
        case R.id.tv_card_services:
          tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.card_details, 0, 0, 0);
          break;
        case R.id.tv_learn_more:
          tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.learn_more, 0, 0, 0);
          break;
        case R.id.tv_personal_details:
          tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.p_details, 0, 0, 0);
          break;
        case R.id.tv_account_details:
          tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.a_details, 0, 0, 0);
          break;
        case R.id.tv_contact_us:
          tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.contact_us, 0, 0, 0);
          break;
        case R.id.tv_store_locator:
          tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.map_locator, 0, 0, 0);
          break;
        case R.id.tv_faq:
          tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.faq, 0, 0, 0);
          break;

        default:
          break;
      }
    }
  }
Example #2
0
  public static Bitmap doColorFilter(Bitmap src, double red, double green, double blue) {
    // image size
    int width = src.getWidth();
    int height = src.getHeight();
    // create output bitmap
    Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig());
    // color information
    int A, R, G, B;
    int pixel;

    // scan through all pixels
    for (int x = 0; x < width; ++x) {
      for (int y = 0; y < height; ++y) {
        // get pixel color
        pixel = src.getPixel(x, y);
        // apply filtering on each channel R, G, B
        A = Color.alpha(pixel);
        R = (int) (Color.red(pixel) * red);
        G = (int) (Color.green(pixel) * green);
        B = (int) (Color.blue(pixel) * blue);
        // set new color pixel to output bitmap
        bmOut.setPixel(x, y, Color.argb(A, R, G, B));
      }
    }

    // return final image
    return bmOut;
  }
Example #3
0
  /** 重写这个方法 */
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    // 获取焦点改变背景颜色.
    int height = getHeight(); // 获取对应高度 1596 samsung s4
    int width = getWidth(); // 获取对应宽度
    int singleHeight = height / b.length; // 获取每一个字母的高度

    for (int i = 0; i < b.length; i++) {
      paint.setColor(Color.rgb(33, 65, 98)); // 右边字母导航条的颜色
      //			paint.setColor(Color.WHITE);
      paint.setTypeface(Typeface.DEFAULT_BOLD);
      paint.setAntiAlias(true);
      paint.setTextSize(height / 320 * 10); // 根据屏幕分辨率设置字体大小
      // 选中的状态
      if (i == choose) {
        paint.setColor(Color.parseColor("#3399ff"));
        paint.setFakeBoldText(true);
      }
      // x坐标等于中间-字符串宽度的一半.
      float xPos = width / 2 - paint.measureText(b[i]) / 2;
      float yPos = singleHeight * i + singleHeight;
      canvas.drawText(b[i], xPos, yPos, paint);
      paint.reset(); // 重置画笔
    }
  }
Example #4
0
 public static int darker(int color) {
   float[] hsv = new float[3];
   Color.colorToHSV(color, hsv);
   hsv[2] = 1.0f - 0.8f * (1.0f - hsv[2]);
   color = Color.HSVToColor(hsv);
   return color;
 }
  public void handle() {
    if (AdViewTargeting.getRunMode() == RunMode.TEST) Log.d(AdViewUtil.ADVIEW, "Into Wooboo");
    AdViewLayout adViewLayout = adViewLayoutReference.get();
    if (adViewLayout == null) {
      return;
    }
    Extra extra = adViewLayout.extra;
    int bgColor = Color.rgb(extra.bgRed, extra.bgGreen, extra.bgBlue);
    int fgColor = Color.rgb(extra.fgRed, extra.fgGreen, extra.fgBlue);
    WoobooAdView adView = null;
    if (AdViewTargeting.getRunMode() == RunMode.TEST)
      adView =
          new WoobooAdView(
              adViewLayout.getContext(), ration.key, bgColor, fgColor, true, 120, null);
    else if (AdViewTargeting.getRunMode() == RunMode.NORMAL)
      adView =
          new WoobooAdView(
              adViewLayout.getContext(), ration.key, bgColor, fgColor, false, 120, null);
    else {
      adView =
          new WoobooAdView(
              adViewLayout.getContext(), ration.key, bgColor, fgColor, false, 120, null);
    }

    adView.setHorizontalScrollBarEnabled(false);
    adView.setVerticalScrollBarEnabled(false);
    adView.setAdListener(this);
    // adViewLayout.adViewManager.resetRollover();
    //	adViewLayout.handler.post(new ViewAdRunnable(adViewLayout, adView));
    //	adViewLayout.rotateThreadedDelayed();

  }
Example #6
0
  /**
   * @param cx Coordenada del centro en el eje X, si se omite se asume 0
   * @param cy Coordenada del centro el en eje Y, si se omite se asume 0
   * @param rx Radio en el eje X
   * @param ry Radio en el eje Y
   * @param rgb Código de color hexadecimal de la forma #FFFFFF
   * @param brgb Código de color hexadecimal de la forma #FFFFFF para el borde
   * @param bwidth Grosor del borde del rectángulo. Debe ser 0 para omitir el borde.
   * @param tr Transformaciones que se aplicarán a la figura
   */
  public BEllipse(
      float cx,
      float cy,
      float rx,
      float ry,
      String rgb,
      String brgb,
      float bwidth,
      Transformations tr) {

    this.tr = tr;
    this.rectElement = new RectF(cx - rx, cy - ry, 2 * rx, 2 * ry);

    this.paintBorder = new Paint();
    if (bwidth > 0) {
      this.paintBorder.setStyle(Paint.Style.STROKE);
      this.paintBorder.setStrokeWidth(bwidth);
      this.paintBorder.setColor(Color.parseColor(brgb));
      this.paintBorder.setAntiAlias(true);
    }

    this.paint = new Paint();
    this.paint.setColor(Color.parseColor(rgb));
    this.paint.setAntiAlias(true);
  }
Example #7
0
  @Override
  public synchronized void onDrawFrame(GL10 gl) {

    mObserver.onDrawFrame();

    if (mBackgroundColorChanged) {
      gl.glClearColor(
          Color.red(mBackgroundColor) / 255f,
          Color.green(mBackgroundColor) / 255f,
          Color.blue(mBackgroundColor) / 255f,
          Color.alpha(mBackgroundColor) / 255f);
      mBackgroundColorChanged = false;
    }

    gl.glClear(GL10.GL_COLOR_BUFFER_BIT); // | GL10.GL_DEPTH_BUFFER_BIT);
    gl.glLoadIdentity();

    if (USE_PERSPECTIVE_PROJECTION) {
      gl.glTranslatef(0, 0, -6f);
    }

    for (int i = 0; i < mCurlMeshes.size(); ++i) {
      mCurlMeshes.get(i).draw(gl);
    }
  }
 private int darkenColor(int color) {
   float[] hsv = new float[3];
   Color.colorToHSV(color, hsv);
   hsv[2] = hsv[2] * 0.75f;
   color = Color.HSVToColor(hsv);
   return color;
 }
 public TouchableSpan() {
   this(
       Color.parseColor("#1caff6"),
       Color.parseColor("#8dd9fd"),
       Color.parseColor("#ffffff"),
       Color.parseColor("#999999"));
 }
 /**
  * @param flag
  * @param bgColor
  * @param baseUrl
  * @param mEBrowserView
  * @author wanglei
  * @createAt 20151124
  * @ps 与原EBrowserView的setBrwViewBackground类似,原方法只设置EBrowserView的背景
  *     当网页设置弹动效果后,上下滑动到边缘后,会露出EBrowserView下面的网页,故应给EBrowserView 父对象EBounceView设置背景,
  *     EBrowserView背景设成透明。
  */
 public void setBounceViewBackground(
     boolean flag, String bgColor, String baseUrl, EBrowserView mEBrowserView) {
   if (flag) {
     if (bgColor.startsWith("#") || bgColor.startsWith("rgb")) {
       int color = BUtility.parseColor(bgColor);
       setBackgroundColor(color);
     } else {
       String path =
           BUtility.makeRealPath(
               BUtility.makeUrl(mEBrowserView.getCurrentUrl(baseUrl), bgColor),
               mEBrowserView.getCurrentWidget().m_widgetPath,
               mEBrowserView.getCurrentWidget().m_wgtType);
       Bitmap bitmap = BUtility.getLocalImg(mContext, path);
       Drawable d = null;
       if (bitmap != null) {
         d = new BitmapDrawable(mContext.getResources(), bitmap);
       }
       int version = Build.VERSION.SDK_INT;
       if (version < 16) {
         setBackgroundDrawable(d);
         setBackgroundColor(Color.argb(0, 0, 0, 0));
       } else {
         setBackground(d);
         setBackgroundColor(Color.argb(0, 0, 0, 0));
       }
     }
   } else {
     setBackgroundColor(Color.TRANSPARENT);
   }
 }
 private void insertarTabs(ViewGroup container) {
   View padre = (View) container.getParent();
   appBar = (AppBarLayout) padre.findViewById(R.id.appbar);
   pestanas = new TabLayout(getActivity());
   pestanas.setTabTextColors(Color.parseColor("#FFFFFF"), Color.parseColor("#FFFFFF"));
   appBar.addView(pestanas);
 }
Example #12
0
  /**
   * Calculate the color using the supplied angle.
   *
   * @param angle The selected color's position expressed as angle (in rad).
   * @return The ARGB value of the color on the color wheel at the specified angle.
   */
  private int calculateColor(float angle) {
    float unit = (float) (angle / (2 * Math.PI));
    if (unit < 0) {
      unit += 1;
    }

    if (unit <= 0) {
      mColor = COLORS[0];
      return COLORS[0];
    }
    if (unit >= 1) {
      mColor = COLORS[COLORS.length - 1];
      return COLORS[COLORS.length - 1];
    }

    float p = unit * (COLORS.length - 1);
    int i = (int) p;
    p -= i;

    int c0 = COLORS[i];
    int c1 = COLORS[i + 1];
    int a = ave(Color.alpha(c0), Color.alpha(c1), p);
    int r = ave(Color.red(c0), Color.red(c1), p);
    int g = ave(Color.green(c0), Color.green(c1), p);
    int b = ave(Color.blue(c0), Color.blue(c1), p);

    mColor = Color.argb(a, r, g, b);
    return Color.argb(a, r, g, b);
  }
  @Override
  protected void onDraw(Canvas canvas) {
    // draw the background and color wheel
    canvas.drawBitmap(mBackground, mBackgroundPosition.x, mBackgroundPosition.y, null);
    canvas.drawBitmap(mWheel, mWheelPosition.x, mWheelPosition.y, null);

    // setup paint for the gradient filling
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Paint.Style.FILL);
    paint.setStrokeWidth(2.0f);
    // create a shader that will show the range of brightness settings
    float[] gradientStartColor = new float[3];
    float[] gradientEndColor = new float[3];
    System.arraycopy(mNewColor, 0, gradientStartColor, 0, mNewColor.length);
    System.arraycopy(mNewColor, 0, gradientEndColor, 0, mNewColor.length);
    gradientStartColor[2] = 1.0f;
    gradientEndColor[2] = 0.0f;
    Shader gradientShader =
        new LinearGradient(
            (float) (mWheelPosition.x + mRadius),
            mWheelPosition.y,
            mOuterArcRect.right,
            mWheelPosition.y + mWheel.getHeight(),
            Color.HSVToColor(gradientStartColor),
            Color.HSVToColor(gradientEndColor),
            Shader.TileMode.MIRROR);
    paint.setShader(gradientShader);
    canvas.drawPath(mArcPath, paint);

    drawHSCrosshairs(canvas);
    drawBrightnessIndicator(canvas);
  }
    private void initGridCell(TextView gridcell, int i) {
      // Get a reference to the Day gridcell
      final Calendar cellDate = daysMap.get(i).getDay();
      float balance = daysMap.get(i).getBalance();
      if (balance < 0) {
        gridcell.setTextColor(Color.parseColor("#B40431"));
      } else if (balance < 100) {
        gridcell.setTextColor(Color.parseColor("#868A08"));
      } else {
        gridcell.setTextColor(Color.parseColor("#088A08"));
      }

      if (cellDate != null) {
        if (cellDate.get(Calendar.MONTH) != currentMonth.get(Calendar.MONTH)) {
          gridcell.setTextColor(Color.parseColor("#A4A4A4"));
        }
        String cellString =
            cellDate.get(Calendar.DAY_OF_MONTH) + "\n\n" + String.format("%.0f", balance);
        gridcell.setText(cellString);
      }
      gridcell.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              if (cellDate != null) {
                Bundle b = new Bundle();
                b.putLong("date", cellDate.getTimeInMillis());
                FragmentManager fm = getSupportFragmentManager();
                Finance_Calendar_Dialog dialog = new Finance_Calendar_Dialog();
                dialog.setArguments(b);
                dialog.show(fm, "ShowInputs");
              }
            }
          });
    }
 private static JSONObject serializeColor(int color) throws JSONException {
   JSONObject jColor = new JSONObject();
   jColor.put("r", Color.red(color));
   jColor.put("g", Color.green(color));
   jColor.put("b", Color.blue(color));
   return jColor;
 }
Example #16
0
 public void paintBitmap(Context context, Canvas c, Rect dest) {
   int color0 = Color.argb(0xFF, 196, 181, 51);
   int color1 = Color.argb(0xFF, 251, 219, 39);
   int color2 = Color.argb(0xFF, 255, 239, 151);
   int border = Color.argb(0xFF, 220, 200, 80);
   Paint p = new Paint();
   p.setAntiAlias(true);
   float width = dest.width() / 20.0f;
   float insideSize = dest.width() - 2 * width;
   RectF inside1 =
       new RectF(
           dest.left + width - 1,
           dest.top + width - 1,
           dest.right - width + 1,
           dest.bottom - width + 1);
   RectF inside =
       new RectF(dest.left + width, dest.top + width, dest.right - width, dest.bottom - width);
   LinearGradient linear =
       new LinearGradient(
           inside1.left,
           inside1.top + insideSize / 3,
           inside1.right,
           inside1.top + 2 * insideSize / 3,
           new int[] {color0, color1, color2},
           null,
           Shader.TileMode.CLAMP);
   p.setShader(linear);
   c.drawRoundRect(inside1, width, width, p);
   p.setShader(null);
   p.setColor(border);
   Path path = new Path();
   path.addRoundRect(inside, width, width, Path.Direction.CCW);
   path.addRect(new RectF(dest), Path.Direction.CW);
   c.drawPath(path, p);
 }
Example #17
0
  Bitmap drawEye() {
    Paint paint_eyebg = new Paint();
    paint_eyebg.setColor(Color.parseColor("#EDEDED"));

    Paint paint_eyerim = new Paint();
    paint_eyerim.setColor(Color.parseColor("#F2E16C"));

    Paint paint_eyeinside = new Paint();
    paint_eyeinside.setColor(Color.parseColor("#FFFFFF"));

    Paint paint_red = new Paint();
    paint_red.setColor(Color.parseColor("#FFE342"));

    Paint paint_black = new Paint();
    paint_black.setColor(Color.parseColor("#000000"));

    Bitmap bg = Bitmap.createBitmap(480, 800, Bitmap.Config.ARGB_8888);
    Canvas canvas_eye = new Canvas(bg);

    Bitmap bg_eyeinside =
        Bitmap.createBitmap(bg.getWidth(), bg.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas_bg_inside = new Canvas(bg_eyeinside);
    canvas_bg_inside.drawOval(new RectF(240, 200, 300, 280), paint_red);
    canvas_bg_inside.drawBitmap(bg_eyeinside, 0, 0, null);

    canvas_eye.drawCircle(230, 200, 60, paint_eyebg);
    canvas_eye.drawCircle(230, 200, 50, paint_eyebg);
    canvas_eye.drawBitmap(bg_eyeinside, -40, -40, null);
    canvas_eye.drawCircle(230, 200, 35, paint_eyeinside);
    canvas_eye.drawCircle(220, 200, 20, paint_black);
    canvas_eye.drawCircle(220, 200, 2, paint_eyebg);

    return bg;
  }
Example #18
0
  private void addData() {
    ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();

    for (int i = 0; i < yData.length; i++) yVals1.add(new BarEntry(yData[i], i));

    ArrayList<String> xVals = new ArrayList<String>();

    for (int i = 0; i < xData.length; i++) xVals.add(xData[i]);

    // create pie data set
    BarDataSet dataSet = new BarDataSet(yVals1, "Stock");
    //	dataSet.setSliceSpace(5);
    //	dataSet.setSelectionShift(5);

    // add many colors
    ArrayList<Integer> colors = new ArrayList<Integer>();
    colors.add(Color.rgb(0, 204, 68));
    colors.add(Color.rgb(230, 0, 0));

    dataSet.setColors(colors);

    // instantiate pie data object
    BarData data = new BarData(xVals, dataSet);

    data.setValueTextSize(16);
    data.setValueTextColor(Color.BLACK);

    mChart.setData(data);

    // undo highlights
    mChart.highlightValue(null);

    // update pie chart
    mChart.invalidate();
  }
Example #19
0
  /**
   * 组合消息文本
   *
   * @param name
   * @param body
   * @return
   */
  public static SpannableStringBuilder parseFriendPostpan(
      String name, SpannableStringBuilder body) {
    SpannableStringBuilder sp = null;
    int start = 0;
    int end = 0;
    String mName = name + ":";
    sp = body.insert(0, mName);
    // sp = new SpannableString(name + ":" + body);
    end = name.length();

    // 设置用户名字体加粗、高亮
    sp.setSpan(
        new StyleSpan(android.graphics.Typeface.BOLD),
        start,
        end,
        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    sp.setSpan(
        new ForegroundColorSpan(Color.parseColor("#2f548f")),
        start,
        end,
        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    sp.setSpan(
        new ForegroundColorSpan(Color.parseColor("#ff000000")),
        end,
        sp.length(),
        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return sp;
  }
    private int rotateColor(int color, float rad) {
      float deg = rad * 180 / 3.1415927f;
      int r = Color.red(color);
      int g = Color.green(color);
      int b = Color.blue(color);

      ColorMatrix cm = new ColorMatrix();
      ColorMatrix tmp = new ColorMatrix();

      cm.setRGB2YUV();
      tmp.setRotate(0, deg);
      cm.postConcat(tmp);
      tmp.setYUV2RGB();
      cm.postConcat(tmp);

      final float[] a = cm.getArray();

      int ir = floatToByte(a[0] * r + a[1] * g + a[2] * b);
      int ig = floatToByte(a[5] * r + a[6] * g + a[7] * b);
      int ib = floatToByte(a[10] * r + a[11] * g + a[12] * b);

      return Color.argb(
          Color.alpha(color), pinToByte(ir),
          pinToByte(ig), pinToByte(ib));
    }
Example #21
0
  /** holo皮肤 */
  private void initWheel2() {
    hourWheelView = (WheelView) findViewById(R.id.hour_wheelview);
    hourWheelView.setWheelAdapter(new ArrayWheelAdapter(this));
    hourWheelView.setSkin(WheelView.Skin.Holo);
    hourWheelView.setWheelData(createHours());
    WheelView.WheelViewStyle style = new WheelView.WheelViewStyle();
    style.selectedTextColor = Color.parseColor("#0288ce");
    style.textColor = Color.GRAY;
    style.selectedTextSize = 20;
    hourWheelView.setStyle(style);
    hourWheelView.setExtraText("时", Color.parseColor("#0288ce"), 40, 70);

    minuteWheelView = (WheelView) findViewById(R.id.minute_wheelview);
    minuteWheelView.setWheelAdapter(new ArrayWheelAdapter(this));
    minuteWheelView.setSkin(WheelView.Skin.Holo);
    minuteWheelView.setWheelData(createMinutes());
    minuteWheelView.setStyle(style);
    minuteWheelView.setExtraText("分", Color.parseColor("#0288ce"), 40, 70);

    secondWheelView = (WheelView) findViewById(R.id.second_wheelview);
    secondWheelView.setWheelAdapter(new ArrayWheelAdapter(this));
    secondWheelView.setSkin(WheelView.Skin.Holo);
    secondWheelView.setWheelData(createMinutes());
    secondWheelView.setStyle(style);
    secondWheelView.setExtraText("秒", Color.parseColor("#0288ce"), 40, 70);
  }
Example #22
0
  /**
   * Calculate the color selected by the pointer on the bar.
   *
   * @param coord Coordinate of the pointer.
   */
  private void calculateColor(int coord) {
    coord = coord - mBarPointerHaloRadius;
    if (coord < 0) {
      coord = 0;
    } else if (coord > mBarLength) {
      coord = mBarLength;
    }

    if (coord > (mBarPointerHaloRadius + (mBarLength / 2))
        && coord < (mBarPointerHaloRadius + mBarLength)) {
      mColor =
          Color.HSVToColor(
              new float[] {
                mHSVColor[0],
                1f,
                (float)
                    (1 - (mPosToSVFactor * (coord - (mBarPointerHaloRadius + (mBarLength / 2)))))
              });
    } else if (coord > mBarPointerHaloRadius && coord < (mBarPointerHaloRadius + mBarLength)) {
      mColor =
          Color.HSVToColor(
              new float[] {
                mHSVColor[0], (float) ((mPosToSVFactor * (coord - mBarPointerHaloRadius))), 1f
              });
    } else if (coord == mBarPointerHaloRadius) {
      mColor = Color.WHITE;
    } else if (coord == mBarPointerHaloRadius + mBarLength) {
      mColor = Color.BLACK;
    }
  }
Example #23
0
  /**
   * Set the bar color. <br>
   * <br>
   * Its discouraged to use this method.
   *
   * @param color
   */
  public void setColor(int color) {
    int x1, y1;
    if (mOrientation == ORIENTATION_HORIZONTAL) {
      x1 = (mBarLength + mBarPointerHaloRadius);
      y1 = mBarThickness;
    } else {
      x1 = mBarThickness;
      y1 = (mBarLength + mBarPointerHaloRadius);
    }

    Color.colorToHSV(color, mHSVColor);
    shader =
        new LinearGradient(
            mBarPointerHaloRadius,
            0,
            x1,
            y1,
            new int[] {Color.HSVToColor(0x00, mHSVColor), color},
            null,
            Shader.TileMode.CLAMP);
    mBarPaint.setShader(shader);
    calculateColor(mBarPointerPosition);
    mBarPointerPaint.setColor(mColor);
    if (mPicker != null) {
      mPicker.setNewCenterColor(mColor);
    }
    invalidate();
  }
  /**
   * Get the white icon corresponding to a poiType.
   *
   * @param poiType the PoiType or null for notes.
   * @return The white icon.
   */
  public Drawable getIconWhite(PoiType poiType) {
    Bitmap myBitmap =
        BitmapFactory.decodeResource(
            context.getResources(),
            poiType == null ? R.drawable.open_book : getIconDrawableId(poiType));
    myBitmap = myBitmap.copy(myBitmap.getConfig(), true);

    int[] allpixels = new int[myBitmap.getHeight() * myBitmap.getWidth()];

    myBitmap.getPixels(
        allpixels, 0, myBitmap.getWidth(), 0, 0, myBitmap.getWidth(), myBitmap.getHeight());

    for (int i = 0; i < myBitmap.getHeight() * myBitmap.getWidth(); i++) {
      if (allpixels[i] != 0) {
        int A = Color.alpha(allpixels[i]);
        // inverting byte for each R/G/B channel
        int R = 255 - Color.red(allpixels[i]);
        int G = 255 - Color.green(allpixels[i]);
        int B = 255 - Color.blue(allpixels[i]);
        // set newly-inverted pixel to output image
        allpixels[i] = Color.argb(A, R, G, B);
      }
    }

    myBitmap.setPixels(
        allpixels, 0, myBitmap.getWidth(), 0, 0, myBitmap.getWidth(), myBitmap.getHeight());

    return new BitmapDrawable(context.getResources(), myBitmap);
  }
Example #25
0
  public static Bitmap applySaturationFilter(Bitmap source, int level) {
    // get image size
    int width = source.getWidth();
    int height = source.getHeight();
    int[] pixels = new int[width * height];
    float[] HSV = new float[3];
    // get pixel array from source
    source.getPixels(pixels, 0, width, 0, 0, width, height);

    int index = 0;
    // iteration through pixels
    for (int y = 0; y < height; ++y) {
      for (int x = 0; x < width; ++x) {
        // get current index in 2D-matrix
        index = y * width + x;
        // convert to HSV
        Color.colorToHSV(pixels[index], HSV);
        // increase Saturation level
        HSV[1] *= level;
        HSV[1] = (float) Math.max(0.0, Math.min(HSV[1], 1.0));
        // take color back
        pixels[index] |= Color.HSVToColor(HSV);
      }
    }
    // output bitmap
    Bitmap bmOut = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    bmOut.setPixels(pixels, 0, width, 0, 0, width, height);
    return bmOut;
  }
Example #26
0
 /**
  * Sets the background color of the scene.
  *
  * @param color Android color integer.
  */
 public void setBackgroundColor(int color) {
   setBackgroundColor(
       Color.red(color) / 255f,
       Color.green(color) / 255f,
       Color.blue(color) / 255f,
       Color.alpha(color) / 255f);
 }
Example #27
0
  @Override
  public View getView(int position, View convertView, ViewGroup viewGroup) {

    Categorias estadoVO = listCategorias.get(position);

    ViewHolder holder;

    if (convertView == null) {
      convertView = inflater.inflate(idLayout, null);

      holder = new ViewHolder();
      holder.qtdLojas = (TextView) convertView.findViewById(R.id.txtQtdLojas);
      holder.icone = (ImageView) convertView.findViewById(R.id.imgIcon);
      holder.title = (TextView) convertView.findViewById(R.id.txtTitle);

      convertView.setTag(holder);

    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    holder.title.setText(estadoVO.getText());
    holder.qtdLojas.setText(String.valueOf(estadoVO.getQtdLojas()));
    holder.icone.setImageResource(estadoVO.getIcon());

    int rgb[] = estadoVO.getRgbColor();

    holder.title.setBackgroundColor(Color.argb(215, rgb[0], rgb[1], rgb[2]));
    holder.icone.setBackgroundColor(Color.rgb(rgb[0], rgb[1], rgb[2]));
    holder.qtdLojas.setBackgroundColor(Color.argb(125, rgb[0], rgb[1], rgb[2]));

    return convertView;
  }
  protected void setupToolbar() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar ab = getSupportActionBar();
    if (ab != null) {
      ab.setDisplayHomeAsUpEnabled(true);
    }

    // Status bar
    if (Build.VERSION.SDK_INT >= 21) {
      getWindow().setStatusBarColor(Color.parseColor(mColors[GridActivity.DARK_PRIMARY]));
    }

    // Entire bar layout
    int barColor = Color.parseColor(mColors[GridActivity.PRIMARY]);
    AppBarLayout barLayout = (AppBarLayout) this.findViewById(R.id.app_bar);
    if (barLayout != null) {
      barLayout.setBackgroundColor(barColor);
    }
    toolbar.setBackgroundColor(barColor);

    CollapsingToolbarLayout collapsingToolbarLayout =
        (CollapsingToolbarLayout) this.findViewById(R.id.toolbar_layout);
    if (collapsingToolbarLayout != null) {
      collapsingToolbarLayout.setBackgroundColor(barColor);
      collapsingToolbarLayout.setContentScrimColor(barColor);
    }
  }
 private void init(Context ctx) {
   setVisible(false);
   mItems = new ArrayList<PieItem>();
   Resources res = ctx.getResources();
   mRadius = (int) res.getDimensionPixelSize(R.dimen.pie_radius_start);
   mCircleSize = mRadius - res.getDimensionPixelSize(R.dimen.focus_radius_offset);
   mRadiusInc = (int) res.getDimensionPixelSize(R.dimen.pie_radius_increment);
   mTouchOffset = (int) res.getDimensionPixelSize(R.dimen.pie_touch_offset);
   mCenter = new Point(0, 0);
   mSelectedPaint = new Paint();
   mSelectedPaint.setColor(Color.argb(255, 51, 181, 229));
   mSelectedPaint.setAntiAlias(true);
   mSubPaint = new Paint();
   mSubPaint.setAntiAlias(true);
   mSubPaint.setColor(Color.argb(200, 250, 230, 128));
   mFocusPaint = new Paint();
   mFocusPaint.setAntiAlias(true);
   mFocusPaint.setColor(Color.WHITE);
   mFocusPaint.setStyle(Paint.Style.STROKE);
   mSuccessColor = Color.GREEN;
   mFailColor = Color.RED;
   mCircle = new RectF();
   mDial = new RectF();
   mPoint1 = new Point();
   mPoint2 = new Point();
   mInnerOffset = res.getDimensionPixelSize(R.dimen.focus_inner_offset);
   mOuterStroke = res.getDimensionPixelSize(R.dimen.focus_outer_stroke);
   mInnerStroke = res.getDimensionPixelSize(R.dimen.focus_inner_stroke);
   mState = STATE_IDLE;
   mBlockFocus = false;
   mTouchSlopSquared = ViewConfiguration.get(ctx).getScaledTouchSlop();
   mTouchSlopSquared = mTouchSlopSquared * mTouchSlopSquared;
   mDown = new Point();
 }
 private int getInverseColor(int color) {
   int red = Color.red(color);
   int green = Color.green(color);
   int blue = Color.blue(color);
   int alpha = Color.alpha(color);
   return Color.argb(alpha, 255 - red, 255 - green, 255 - blue);
 }