Exemplo n.º 1
0
  public static Bitmap[] load(String src, int width, int height) {
    Bitmap[] texture = null;
    InputStream is = null;
    AssetManager am = resources.getAssets();
    String[] nameOfBoxs = null;

    try {
      nameOfBoxs = am.list(src);
    } catch (IOException e) {
      Log.d("GraphicMaster", "Culd not find folder " + src);
    }

    Log.d("GraphicMaster", "NameOfBoxs.length = " + nameOfBoxs.length);
    texture = new Bitmap[nameOfBoxs.length];

    for (int i = 0; i < nameOfBoxs.length; i++) {
      try {
        is = resources.getAssets().open(src + "/" + nameOfBoxs[i]);

        texture[i] = BitmapFactory.decodeStream(is);

        /*	if(width > 0 && height > 0)
        texture[i] = Bitmap.createScaledBitmap(texture[i], width, height, false);*/

        Log.d(
            "GraphicMaster",
            "Scaled from "
                + new Integer((int) (texture[i].getWidth())).toString()
                + " "
                + new Integer((int) (texture[i].getHeight())).toString()
                + " to "
                + new Integer((int) (texture[i].getWidth() * GameSettings.widthM)).toString()
                + " "
                + new Integer((int) (GameSettings.heightM * texture[i].getWidth())).toString());

        Log.d(
            "GraphicMaster",
            "Scale"
                + new Double(GameSettings.widthM).toString()
                + " "
                + new Double(GameSettings.heightM).toString());

        if (GameSettings.widthM != 1 && GameSettings.heightM != 1)
          texture[i] =
              Bitmap.createScaledBitmap(
                  texture[i],
                  (int) (texture[i].getWidth() * GameSettings.widthM),
                  (int) (texture[i].getHeight() * GameSettings.heightM),
                  false);

      } catch (IOException e) {
        Log.d("GraphicMaster", "Culd not read: " + src + nameOfBoxs[i]);
      }
    }

    return texture;
  }
Exemplo n.º 2
0
  private void downloadImage() {
    String myURL = equip.getImage_url();

    try {
      URL url = new URL(myURL);
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      bitmap = BitmapFactory.decodeStream(conn.getInputStream());
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
   if (requestCode == FILECHOOSER_RESULTCODE) { // found this from StackOverflow
     if (null == mUploadMessage) return;
     Uri result = intent == null || resultCode != RESULT_OK ? null : intent.getData();
     mUploadMessage.onReceiveValue(result);
     mUploadMessage = null;
   } else {
     // -----------I wrote this code below this line----------------------------------
     jpegData = intent.getExtras().getByteArray("image");
     Bitmap img = BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length);
     Drawable d = new BitmapDrawable(img);
     profilePicture.setBackground(d);
   }
 }
Exemplo n.º 4
0
 public MyView(Context context) {
   super(context);
   mBack = BitmapFactory.decodeResource(context.getResources(), R.drawable.family);
   mHandler.sendEmptyMessageDelayed(0, DELAY);
 }