标签: bitmap

如何将较小的位图复制到较大的位图?

希望这应该是一个简单的问题.我正在尝试将一系列小位图复制到一个较大的位图中,将它们并排排列,没有任何间隙或像素重叠.例如,如果我有3个方形位图,我想将它们复制到一个长而细的矩形中.我知道如何做相反的事情,即从较大的位图创建一个小位图,但不是这样.什么是正确的命令?

(如果有人好奇,我想这样做是为了能够重用我为处理带有单个位图的动画而编写的代码.)

谢谢!

android canvas bitmap

8
推荐指数
1
解决办法
3818
查看次数

创建图形并将其另存为位图

我有两个问题:

1)我有一个PictureBox,它的Dock设置为Fill.当我调整大小时,Form我无法在PictureBox扩展的部分创建图形.问题是什么?

2)我想转换是在创建的图形PictureBox来Bitmap并将其保存为*.jpg或*.BMP.我怎样才能做到这一点?

.net c# bitmap picturebox

8
推荐指数
1
解决办法
2万
查看次数

Uri表示子文件夹中的位图(c#wpf)

我有一个wpf应用程序,我正在使用图像.要参考我使用的图像:

Uri uri = new Uri("pack://application:,,,/assemblyName;Component/myIcon.png");
BitmapImage(uri)
Run Code Online (Sandbox Code Playgroud)

如果我直接在csproj文件下添加png(其属性BuildAction = Resource),那么它可以正常工作.

但我想将它移动到csproj下的子文件夹中.关于位图\ uri的另一个问题(857732)以及与这个msdn有关的答案.所以我尝试过:

Uri uri = new Uri("pack://application:,,,/assemblyName;Component/Icons/myIcon.png");
Run Code Online (Sandbox Code Playgroud)

但那没用.

有任何想法吗?

c# uri bitmap

8
推荐指数
1
解决办法
2万
查看次数

如何从Android中的大位图加载切片?

如果我有一个通常会产生"内存不足"异常的大型位图文件,我该如何将其加载为tile?例如,我有10,000x10,000的图像,我想将其分成10x10网格的1,000x1,000像素图块.

我见过这个功能,Bitmap.createBitmap(sourceBitmap, x, y, width, height)但它需要我的大图像作为源输入.

如何在不完全加载输入图像的情况下从输入图像中获取图块?

java android memory-management bitmap

8
推荐指数
1
解决办法
2万
查看次数

捕获的照片方向在android中正在发生变化

我点击按钮打开相机应用程序.并在下一个活动中显示捕获的照片.但捕获的照片旋转了90度.当我捕捉到图像后在视图中显示图像时,它的方向始终是横向的.为什么在纵向模式下拍摄照片时,照片不会以纵向显示?

点击按钮:

Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(APP_DIR+"/latest.png")));       
startActivityForResult(i, CAPTURE_PHOTO_CONSTANT);
Run Code Online (Sandbox Code Playgroud)

在onActvityresult里面:

bmp = BitmapFactory.decodeFile(APP_DIR+"/latest.png");
startActivity(new Intent(this, DisplayActivity.class));
Run Code Online (Sandbox Code Playgroud)

显示拍摄的照片:

photoViewRelativeLayout.setBackgroundDrawable(new BitmapDrawable(getResources(), CaptureActivity.bmp));
Run Code Online (Sandbox Code Playgroud)

camera android bitmap

8
推荐指数
1
解决办法
2万
查看次数

在c中读/写bmp文件

我正在尝试使用bmp文件.首先,我尝试从bmp文件中读取标头和数据,并将其写入新文件:

#pragma pack(push,1)
/* Windows 3.x bitmap file header */
typedef struct {
    char         filetype[2];   /* magic - always 'B' 'M' */
    unsigned int filesize;
    short        reserved1;
    short        reserved2;
    unsigned int dataoffset;    /* offset in bytes to actual bitmap data */
} file_header;

/* Windows 3.x bitmap full header, including file header */
typedef struct {
    file_header  fileheader;
    unsigned int headersize;
    int          width;
    int          height;
    short        planes;
    short        bitsperpixel;  /* we only support the value 24 here */
    unsigned int …
Run Code Online (Sandbox Code Playgroud)

c bitmap

8
推荐指数
1
解决办法
1万
查看次数

如何在android中的第一个图像上的选定点合并两个位图?

我如何将两个不同的图像合并为一个.此外,我需要在第一个图像上的特定点合并第二个图像.它在android中是否可行?

android bitmap drawbitmap

8
推荐指数
1
解决办法
1144
查看次数

android比例位图性能

我有这个:

paint = new Paint();
paint.setAntiAlias(true);
paint.setFilterBitmap(true);
paint.setDither(true);

sm = new Matrix();
sm.setScale(scale, scale);

private Bitmap getImage(String n) {
    File dir = context.getDir("theme", Context.MODE_PRIVATE);
    File file = new File(dir, n + ".png");
    if (file.exists()) {
       return BitmapFactory.decodeFile(file.getAbsolutePath());
    } else {
        return BitmapFactory.decodeResource(getResources(), getResources().getIdentifier(n, "drawable", getPackageName()));
    }
}

private Bitmap resizeImage(Bitmap b) {
    return Bitmap.createBitmap(b, 0, 0, b.getWidth(), b.getHeight(), sm, true);
}

public void onTouchEvent(MotionEvent event) {
    #scrollable bitmaps, parallax effect
    updatePosition();
}

private void draw() {
    current_time = System.currentTimeMillis();
    if …
Run Code Online (Sandbox Code Playgroud)

android canvas bitmap

8
推荐指数
1
解决办法
2377
查看次数

使用glide将位图加载到ImageView

我想在裁剪和重新调整位图大小后使用Glide将位图加载到ImageView.

我不想使用,ImageView.setImageBitmap(bitmap);因为我正在加载大量图像,它可能会占用一些内存,虽然图像尺寸很小,我只需要使用Glide,因为我知道它可以优化图像缓存.

我读了这篇文章,但是当我尝试实现它时,我并不完全理解他的解决方案.所以也许某人有一个更清洁,更容易理解的解决方案.

这是我的代码,它拾取图像并从中创建一个位图.

我需要使用滑行代替ImageView.setImageBitmap(bitmap);.

new AsyncTask<String, Void, Void>() {
    Bitmap theBitmap = null;
    Bitmap bm = null;

    @Override
    protected Void doInBackground(String... params) {
        String TAG = "Error Message: ";
        try {
            //Load the image into bitmap
            theBitmap = Glide.
                    with(mContext).
                    load("http://example.com/imageurl").
                    asBitmap().
                    into(-1, -1).
                    get();

            //resizes the image to a smaller dimension out of the main image.
            bm = Bitmap.createBitmap(theBitmap, 0, 0, 210, 80);
        } catch (final ExecutionException e) {
            Log.e(TAG, e.getMessage());
        } …
Run Code Online (Sandbox Code Playgroud)

java android bitmap android-glide

8
推荐指数
1
解决办法
2万
查看次数

如何在Android中的位图压缩后保存Exif数据

我需要从SD卡获取图像,创建,旋转和保存更改的图像.我尝试使用此代码

Bitmap original = BitmapFactory.decodeFile(file.getAbsolutePath());

    ExifInterface originalExif = new ExifInterface(file.getAbsolutePath());
    int orientation = originalExif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);

    Matrix matrix = new Matrix();
    int rotate = 90;
    if(orientation == ExifInterface.ORIENTATION_ROTATE_90){
        rotate = 180;
    }else if(orientation == ExifInterface.ORIENTATION_ROTATE_180){
        rotate = 270;
    }else if(orientation == ExifInterface.ORIENTATION_ROTATE_270){
        rotate = 0;
    }

    matrix.postRotate(rotate);

    Bitmap bitmap = Bitmap.createBitmap(original, 0, 0, original.getWidth(), original.getHeight(), matrix, true);

    try {
        FileOutputStream out = new FileOutputStream(file);
        bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
        out.flush();
        out.close();

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        original.recycle();
        bitmap.recycle();
    } …
Run Code Online (Sandbox Code Playgroud)

android bitmap

8
推荐指数
1
解决办法
5964
查看次数

标签 统计

bitmap ×10

android ×7

c# ×2

canvas ×2

java ×2

.net ×1

android-glide ×1

c ×1

camera ×1

drawbitmap ×1

memory-management ×1

picturebox ×1

uri ×1