Exemplo n.º 1
0
  public String encodeImageView(ImageView imageview) {
    String imageString = "";
    try {
      imageview.setDrawingCacheEnabled(true);
      Bitmap bitmap = imageview.getDrawingCache();
      imageString = encodeBitmap(bitmap);
      imageview.setDrawingCacheEnabled(false);
    } catch (Exception e) {
      e.printStackTrace();
    }

    return imageString;
  }
Exemplo n.º 2
0
 public void setHeadView(View headView) {
   this.headView = headView; // 将 view 设置为 headview 然后添加进去
   imageView = (ImageView) headView.findViewById(R.id.iv);
   Log.e("listview", "====" + imageView.getHeight());
   initHeight = imageView.getHeight(); // 将图片控件的初始高度设置后默认的初始值,用于图片回弹
   imageView.setDrawingCacheEnabled(true);
   //        Bitmap drawingCache = imageView.getDrawingCache();
   //        if (drawingCache != null) {
   //            MaxOverY = imageView.getDrawingCache().getHeight();//将图片的高度设置为最大滑动高度
   //        }
   MaxOverY = imageView.getDrawable().getIntrinsicHeight(); // 获取imageview 上面图片的高度
   imageView.setDrawingCacheEnabled(false);
   //        addHeaderView(headView);
 }
Exemplo n.º 3
0
 public int getHotspotColor(int hotspotId, int x, int y) {
   ImageView img = (ImageView) findViewById(hotspotId);
   if (img == null) {
     Log.d("ImageAreasActivity", "Hot spot image not found");
     return 0;
   } else {
     img.setDrawingCacheEnabled(true);
     Bitmap hotspots = Bitmap.createBitmap(img.getDrawingCache());
     if (hotspots == null) {
       Log.d("ImageAreasActivity", "Hot spot bitmap was not created");
       return 0;
     } else {
       img.setDrawingCacheEnabled(false);
       return hotspots.getPixel(x, y);
     }
   }
 }
Exemplo n.º 4
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   imageView = new ImageView(this);
   imageView.setDrawingCacheEnabled(false);
   loader =
       new ImageLoader(
           LoadServices.newHttpImageNoCache(this),
           null,
           getResources().getDrawable(drawable.icon));
   setContentView(imageView);
 }
Exemplo n.º 5
0
 private File getImageBitmap() {
   mImageView.setDrawingCacheEnabled(true);
   Bitmap bitmap = mImageView.getDrawingCache();
   File filepath = Environment.getExternalStorageDirectory();
   File dir = new File(filepath.getAbsolutePath() + "/Pictures/TechTatva15/");
   dir.mkdirs();
   count = getSharedPreferenceInteger(getApplicationContext(), "COUNT");
   File file = new File(dir, "IMG_INSTA_" + String.valueOf(count) + ".png");
   OutputStream output;
   try {
     output = new FileOutputStream(file);
     bitmap.compress(Bitmap.CompressFormat.PNG, 100, output);
     output.flush();
     output.close();
     f = true;
   } catch (Exception e) {
     e.printStackTrace();
     f = false;
   }
   return file;
 }
Exemplo n.º 6
0
  @SuppressLint("NewApi")
  public PhotoViewAttacher(ImageView imageView) {
    mImageView = imageView;

    imageView.setDrawingCacheEnabled(true);
    imageView.setOnTouchListener(this);

    ViewTreeObserver observer = imageView.getViewTreeObserver();
    if (null != observer) observer.addOnGlobalLayoutListener(this);

    // Make sure we using MATRIX Scale Type
    setImageViewScaleTypeMatrix(imageView);

    if (imageView.isInEditMode()) {
      return;
    }
    // Create Gesture Detectors...
    mScaleDragDetector = VersionedGestureDetector.newInstance(imageView.getContext(), this);

    mGestureDetector =
        new GestureDetector(
            imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

              // forward long click listener
              @Override
              public void onLongPress(MotionEvent e) {
                if (null != mLongClickListener) {
                  mLongClickListener.onLongClick(getImageView());
                }
              }
            });

    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));

    // Finally, update the UI so that we're zoomable
    setZoomable(true);
  }
    public View getView(int position, View convertView, ViewGroup parent) {
      ImageView i = new ImageView(mContext);
      switch (imageIdTarget) {
        case 0:
          i.setImageResource(mImageIds1[position]);
          break;
        case 1:
          i.setImageResource(mImageIds2[position]);
          break;
        case 2:
          i.setImageResource(mImageIds3[position]);
          break;

        case 3:
          i.setImageResource(mImageIds4[position]);
          break;

        case 4:
          i.setImageResource(mImageIds5[position]);
          break;

        default:
          i.setImageResource(mImageIds1[position]);
          break;
      }

      i.setScaleType(ImageView.ScaleType.FIT_CENTER);

      i.setLayoutParams(new mygallery.LayoutParams(250, 250));
      i.setDrawingCacheEnabled(true);
      i.setBackgroundColor(0xFF000000);

      // The preferred Gallery item background
      // i.setBackgroundResource(mGalleryItemBackground);

      return i;
    }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View v = inflater.inflate(R.layout.wallpaper_effects, container, false);

    mWall = (ImageView) v.findViewById(R.id.wall);
    mBlur = (SeekBar) v.findViewById(R.id.sb_blur);
    mApply = (Button) v.findViewById(R.id.btn_apply);
    mWall.setDrawingCacheEnabled(true);
    mBlur.setMax(25);

    mBlur.setOnSeekBarChangeListener(this);
    mApply.setOnClickListener(this);

    wallpaperManager = WallpaperManager.getInstance(getActivity());
    final Drawable wallpaperDrawable = wallpaperManager.getDrawable();

    mWall.setImageDrawable(wallpaperDrawable);

    source = drawableToBitmap(wallpaperDrawable);

    return v;
  }
Exemplo n.º 9
0
  // 取得服务器数据的方法
  private void getData(String i) {
    String md;
    md = ServerDataInterface.getMD5("11" + i + "adc5674059f996cc34baf91556cdb2cb");
    // 大图
    String urlStr =
        "http://app.games.cntv.cn/api.php?op=mobileapplist&client=1&type=1&pagesize=20&catid="
            + i
            + "&ishot=1&md5="
            + md;
    tuijian_res = ServerDataInterface.httpGet(urlStr);
    JsonUtils js = new JsonUtils();
    news_tuijian_title.setText("暂无信息");
    news_center_img.setImageResource(R.drawable.news_index_img);
    if (tuijian_res != null) {
      picList = js.parseListJson(tuijian_res, String.valueOf(i)); // 推荐新闻的List
      if (picList != null && picList.size() != 0) {
        String thumb1;
        NewsTools.Tag = 1;
        NewsTools.mobileId = picList.get(0).getMobileid();
        NewsTools.collect_Mobileid = picList.get(0).getMobileid(); // 获取的内容的Id
        NewsTools.collect_Title = picList.get(0).getTitle(); // 取得推荐新闻的标题
        NewsTools.collect_Ctitle = picList.get(0).getCtitle(); // 取得推荐新闻的副标题
        NewsTools.collect_Thumb = thumb1 = picList.get(0).getThumb(); // 取得推荐新闻的图片地址
        NewsTools.collect_Catid = picList.get(0).getCatid(); // 取得推荐新闻Catid
        NewsTools.Collect_inputtime = picList.get(0).getInputtime(); // 取得推荐新闻的时间戳
        /*				char[] ch = NewsTools.collect_Title.toCharArray();
        String ss ="";
        for(int t=0;t<ch.length;t++){
        	if(ch[t]=='《'){
        		ss = ss+"(";
        	}else if(ch[t]=='》'){
        		ss = ss+")";
        	}else{
        		ss = ss+ch[t];
        	}
        }*/

        news_tuijian_title.setText(NewsTools.collect_Title);
        // 调用异步加载图片的方法
        news_center_img.setImageResource(R.drawable.news_index_img_loading);
        news_center_img.setTag(thumb1);
        new NewsTools.ImageLoadTask().execute(news_center_img);
        news_center_img.setDrawingCacheEnabled(true);
      } else {
        NewsTools.Tag = 0;
      }
    } else {
      NewsTools.Tag = 0;
      Toast.makeText(this, "抱歉,网络请求出现异常,请检查网络!", Toast.LENGTH_SHORT).show();
    }

    // 列表
    news_res =
        ServerDataInterface.httpGet(
            "http://app.games.cntv.cn/api.php?op=mobileapplist&client=1&type=1&catid="
                + i
                + "&md5="
                + md);

    if (news_res != null) {
      // 列表里面显示的新闻列表
      dataList = js.parseListJson(news_res, String.valueOf(i));
      Log.i("news_res", "" + news_res);
    } else {
      Toast.makeText(this, "抱歉,网络请求出现异常,请检查网络!", Toast.LENGTH_SHORT).show();
    }
  }
Exemplo n.º 10
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.avatar_layout);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    Intent i = getIntent();
    option = i.getIntExtra("option", 1);
    points = i.getIntExtra("points", 45); // default - 0 points
    torsoOption = i.getIntExtra("torsoID", -1);
    hairOption = i.getIntExtra("hairID", -1);
    legsOption = i.getIntExtra("legsID", -1);
    eyesOption = i.getIntExtra("eyesID", -1);
    mouthOption = i.getIntExtra("mouthID", -1);
    noseOption = i.getIntExtra("noseID", -1);

    ImageView torsoImage = (ImageView) findViewById(R.id.imageViewAvatarMenu1);
    ImageView legsImage = (ImageView) findViewById(R.id.imageViewAvatarMenu4);
    ImageView hairImage = (ImageView) findViewById(R.id.imageViewAvatarMenu3);
    ImageView noseImage = (ImageView) findViewById(R.id.imageViewAvatarMenu6);
    ImageView eyesImage = (ImageView) findViewById(R.id.imageViewAvatarMenu5);
    ImageView mouthImage = (ImageView) findViewById(R.id.imageViewAvatarMenu7);
    ImageView avatarHelp = (ImageView) findViewById(R.id.imageView1);
    System.out.println("points " + points);

    displayPoints = (TextView) findViewById(R.id.textViewNoPoints);

    displayPoints.setText(points + "");

    if ((torsoOption != -1) && (legsOption != -1) && (hairOption != -1)) {
      torsoImage.setImageResource(torsoOption);
      legsImage.setImageResource(legsOption);
      hairImage.setImageResource(hairOption);
    }

    if ((mouthOption != -1) || (noseOption != -1) || (eyesOption != -1)) {
      mouthImage.setImageResource(mouthOption);
      noseImage.setImageResource(noseOption);
      eyesImage.setImageResource(eyesOption);
    }

    if ((torsoOption != -1)
        && (legsOption != -1)
        && (hairOption != -1)
        && (noseOption != -1)
        && (mouthOption != -1)
        && (eyesOption != -1)) {
      torsoImage.setImageResource(torsoOption);
      legsImage.setImageResource(legsOption);
      hairImage.setImageResource(hairOption);
      noseImage.setImageResource(noseOption);
      eyesImage.setImageResource(eyesOption);
      mouthImage.setImageResource(mouthOption);
    }

    hanger = (ImageView) findViewById(R.id.hangerImage);
    hanger.setDrawingCacheEnabled(true);
    hanger.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            System.out.println("Hanger");
            Intent in = new Intent(AvatarHomePage.this, MainView.class);
            in.putExtra("points", points);
            in.putExtra("eyesID", R.drawable.eyes3);
            in.putExtra("noseID", R.drawable.nose1);
            in.putExtra("mouthID", R.drawable.mouth3);
            in.putExtra("torsoID", R.drawable.torso1);
            in.putExtra("legsID", R.drawable.legs1);
            in.putExtra("hairID", R.drawable.hair1);
            startActivity(in);
          }
        });

    hangerPlus = (ImageView) findViewById(R.id.hangerPlusImage);
    hangerPlus.setDrawingCacheEnabled(true);
    hangerPlus.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            System.out.println("Hanger Plus");
            Intent in = new Intent(AvatarHomePage.this, ShopsView.class);
            in.putExtra("points", points);
            in.putExtra("eyesID", eyesOption);
            in.putExtra("noseID", noseOption);
            in.putExtra("mouthID", mouthOption);
            startActivity(in);
          }
        });

    avatarHelp.setDrawingCacheEnabled(true);
    avatarHelp.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {

            Intent in = new Intent(AvatarHomePage.this, AvatarHelp.class);
            in.putExtra("option", 1);
            in.putExtra("points", points);
            startActivity(in);
            overridePendingTransition(R.anim.bottom_slide_in, R.anim.bottom_slide_out);
          }
        });
  }
Exemplo n.º 11
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    adpt = new GalleryAdapter(this);
    pics = new Vector<Image>();

    previews = (Gallery) findViewById(R.id.gallery1);
    Main = (ImageView) findViewById(R.id.PictureView);
    hist = (Histogram) findViewById(R.id.histogram);
    saturation = (SeekBar) findViewById(R.id.saturation);
    contrast = (SeekBar) findViewById(R.id.contrast);
    exposure = (SeekBar) findViewById(R.id.exposure);
    saveButton = (Button) findViewById(R.id.save);

    contrast.setProgress(50);
    exposure.setProgress(50);
    saturation.setProgress(100);

    handler = new UIHandler(Main, hist);
    tm = new ThreadManager(handler);
    save = new Save();
    save.setContainer(Main);

    PinchyZoomy pz = new PinchyZoomy();

    Main.setOnTouchListener(pz);
    Main.setDrawingCacheEnabled(true);
    Main.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);

    File folder = new File("/sdcard");

    for (int i = 0; i < folder.listFiles().length; i++) {
      String name = folder.listFiles()[i].getName();
      if (folder.listFiles()[i].isFile()) {
        String extension = name.substring(name.length() - 3);
        if (extension.equals("NEF") || extension.equals("dng")) {
          Image temp = new Image(folder.listFiles()[i].getAbsolutePath());
          pics.add(temp);
        }
      }
    }

    for (int i = 0; i < pics.size(); i++) {
      System.out.println("Pulling thumb for: " + pics.elementAt(i).path);
      adpt.addImage(pics.elementAt(i).getThumb());
    }

    previews.setAdapter(adpt);
    previews.setSpacing(3);

    previews.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Main.setImageBitmap(adpt.getItemAt(position));
            Main.setAlpha(100);

            if (current != null) current.free();

            current = pics.elementAt(position);
            handler.setImage(current);
            tm.pic = current;
            save.setImage(current);

            contrast.setProgress(50);
            exposure.setProgress(50);
            saturation.setProgress(100);

            LoadImageThread t = new LoadImageThread(current, handler);
            t.start();
          }
        });

    saturation.setOnSeekBarChangeListener(
        new OnSeekBarChangeListener() {

          @Override
          public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {

            if (current.colors != null) tm.setSaturation(saturation.getProgress());
          }

          @Override
          public void onStartTrackingTouch(SeekBar arg0) {}

          @Override
          public void onStopTrackingTouch(SeekBar arg0) {}
        });
    contrast.setOnSeekBarChangeListener(
        new OnSeekBarChangeListener() {

          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (current.colors != null) tm.setContrast(contrast.getProgress());
          }

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

          }
        });
    exposure.setOnSeekBarChangeListener(
        new OnSeekBarChangeListener() {

          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (current.colors != null) tm.setExposure(exposure.getProgress());
          }

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

          }
        });

    saveButton.setOnClickListener(save);
  }