标签: image-rotation

将UIImage或UIView旋转到特定角度,而不是角度

适用于iOS的Objective-C.

如何将图像或视图旋转到特定角度.我已经尝试了下面的两种方法,但都旋转角度的AMOUNT,而不是角度.基本上我想调用一个方法旋转到90',然后再调用180',图像/视图完成180',而不是添加它们(270')如果我使用会发生什么以下两种方法之一.

#define degreesToRadians(degrees) (M_PI * degrees / 180.0)

myImage.transform = CGAffineTransformMakeRotation(degreesToRadians(90));

myImage.transform = CGAffineTransformRotate(myImage.transform, degreesToRadians(90));
Run Code Online (Sandbox Code Playgroud)

非常感谢!

iphone objective-c rotation image-rotation

5
推荐指数
1
解决办法
6719
查看次数

如何使用c#从图像中裁剪十字矩形?

我想得到图像的一些特定部分,所以我正在裁剪图像.但是,当我想得到一个与图像不平行的部分时,我会旋转图像然后裁剪.

我不想旋转图像并裁剪一个平行的矩形.我想要的是,在不旋转图像的情况下,从图像中裁剪出一个角度的矩形.

有没有办法做到这一点?

我想我不能很好地表达自己.这就是我想要做的:示例图片.

假设红色的东西是一个矩形:)我想从图像中裁剪出那个东西.裁剪后,它不需要是天使.所以mj可以躺下来.

c# crop image-processing image-rotation

5
推荐指数
1
解决办法
2250
查看次数

图像旋转和缩放的jquery问题

我正在尝试向网页添加功能,允许用户旋转和放大图像.我发现了许多允许缩放的jquery插件.没有,也做旋转.因此,我正在尝试使用jquery插件进行缩放/平移以及CSS处理旋转,但到目前为止还没有成功.如果我在添加jquery插件之前或之后应用CSS似乎并不重要.或者将它们链接在一起(再次尝试在缩放插件之前和之后旋转以进行链接,似乎没有任何工作).

供参考,我的代码如下:

HTML:

<body>
    <script src="scripts/jquery-1.6.4.js" type="text/javascript"></script>
    <script src="zoom_assets/jquery.smoothZoom.min.js" type="text/javascript"></script>
    <script src="scripts/PictureViewer_SmoothZoom.js" type="text/javascript"></script>

    <img src="images/leaftemple11680.jpg" id="leafTemple" />
</body>
Run Code Online (Sandbox Code Playgroud)

CSS:

.rotate90Left{
    /* for firefox, safari, chrome, etc. */
    -webkit-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    /* for ie */
    filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
}
Run Code Online (Sandbox Code Playgroud)

JavaScript的:

//jquery chain - add CSS second
$(document).ready(function(){

    $('#leafTemple').smoothZoom({
        width: 480,
        height: 360
    }).addClass('rotate90Left');

});
Run Code Online (Sandbox Code Playgroud)

我正在使用的zoom/pan插件来自这里:

http://codecanyon.net/item/smooth-zoom-pan-jquery-image-viewer/511142

jquery image image-rotation image-zoom

5
推荐指数
1
解决办法
4086
查看次数

jQuery身体背景图像旋转器

对于我目前正在设计的网站,我希望在一组图像的旋转上具有正文背景.我尝试了多种方法,即使用fadeIn()和fadeOut()函数,但它们似乎影响了体内分裂的不透明度.我也尝试过使用bgStretcher但这会导致外观问题,并使网站变得缓慢而且波涛汹涌.

我最好喜欢图像淡入淡出.帮助将不胜感激,

这是网站链接我目前修改的脚本文件在/ js /目录下称为background.js.该文件目前已被注释掉,因为它只是实验性的.两个当前的背景图像是"images/bg/bg1.jpg"和"images/bg/bg2.jpg"

这是我目前正在努力工作的代码:

$(document).ready(function() {
    setInterval(switchImage, 5000);
    switchImage();

});

function switchImage()
{
$('body').css("background-image", "url(../images/bg/bg2.jpg)").fadeIn(1000);
$('body').css("background-image", "url(../images/bg/bg1.jpg)").fadeOut(1000);
}
Run Code Online (Sandbox Code Playgroud)

一旦我弄清楚如何在背景图像之间转换,我可以简单地添加一些条件来在图像数组之间进行更改.

干杯,戴恩威尔逊

css jquery background slider image-rotation

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

使用 CGImageSourceRef 加载图像时旋转错误

我使用下面的代码在 C++ 库中加载图像。加载某些图像时,图像的旋转是错误的。它似乎会影响来自 iPhone 相机的 JPEG。我该如何解决?

据推测,某处有一个标志为相机捕获的 JPEG 设置。我不确定以这种方式加载图像时如何访问它。

CGImageSourceRef source = CGImageSourceCreateWithURL(url, NULL);
CFRelease(url);

if(source==NULL)
    return IM_ErrFileError;

CGImageRef image = CGImageSourceCreateImageAtIndex(source, 0, NULL);
CFRelease(source);

if(image==NULL)
    return IM_ErrFileError;

int w = (int)CGImageGetWidth(image);
int h = (int)CGImageGetHeight(image);

im::Err err = img.Create(im::IntSize(w, h), bands, sizeof(uint8_t), imgtype);
if(IM_FAILED(err))
{
    CGImageRelease(image);
    return err;
}

img.Clear();

CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(colorspacename);
if(colorSpace==NULL)
{
    CGImageRelease(image);
    return IM_ErrAlloc;
}

// Create RGBA context
CGContextRef context = CGBitmapContextCreate(img.BytePtr(), w, h, 8, img.StrideBytes(), colorSpace, alphainfo);

if(context==NULL)
{
    CGColorSpaceRelease(colorSpace);
    CGImageRelease(image);
    return …
Run Code Online (Sandbox Code Playgroud)

macos image-rotation cgimagesource

5
推荐指数
1
解决办法
1034
查看次数

如何正确旋转位图?

旋转位图我遇到了很多麻烦.下面的代码有效,但它比Galaxy Note 2手机附带的Gallery应用程序慢4-6倍.

码:

    File DirectoryFile = new File(Image_Path); 
    Bitmap bitmap = BitmapFactory.decodeFile(DirectoryFile.getAbsolutePath()); 



    String imagePATH = FileLocation + "test.jpg";
    final File newfile = new File(imagePATH);           

    FileOutputStream mFileOutputStream = null;
    try {                   
           mFileOutputStream = new FileOutputStream(newfile);
       } catch (FileNotFoundException e1) { }

        try {
        Bitmap RotatedBitmap =  RotateImage(imagePATH, bitmap);
        RotatedBitmap.compress(Bitmap.CompressFormat.JPEG, 100, mFileOutputStream);
        bitmap.recycle(); 
        RotatedBitmap.recycle();

        mFileOutputStream.flush();
        mFileOutputStream.close();

    } catch (IOException e) {
        e.printStackTrace();
    }

private Bitmap RotateImage(String filePath, Bitmap bitmap) throws IOException {
    ExifInterface exif = new ExifInterface(filePath);
    int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, …
Run Code Online (Sandbox Code Playgroud)

android bitmap matrix image-rotation

5
推荐指数
1
解决办法
306
查看次数

从Gallery使用Android中的filedescriptor和parcelfiledescriptor获取图像旋转

我想使用比android kitkat高的设备获取图像。目前,我使用filedescriptor和parcelfiledescriptor来获取图像。我成功获得图像,但是旋转了。由于图片存储在Google驱动器上,因此我无法直接使用inputstream。我该如何解决?(我知道图像数据通常存储在exif中,但如果尝试获取exif数据,旋转始终为0),我也尝试过使用lib:https//github.com/coomar2841/image-chooser-library,但我在这里得到同样的问题。

           ParcelFileDescriptor parcelFileDescriptor;
        try {
            parcelFileDescriptor = activity.getContentResolver().openFileDescriptor(selectedImage, "r");

            FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();

            Bitmap image = BitmapFactory.decodeFileDescriptor(fileDescriptor);
            image = ExifUtil.rotateBitmap(selectedImagePath, image);
            parcelFileDescriptor.close();
            if (cropCircle) {
                imageView.setImageBitmap(ImageUtils.cutCircle(image));
            } else {
                imageView.setImageBitmap(image);
            }
            return image;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
Run Code Online (Sandbox Code Playgroud)

android gallery drive image-rotation google-photos

5
推荐指数
0
解决办法
491
查看次数

在 Android 中捏缩放和 2 指旋转 ImageView

我在过去 2 天遇到了一个问题,因为我是新手,所以无法解决它。实际上,我正在开发一个需要在 Android ImageView 上进行缩放和两指旋转的 Android 应用程序。我得到了多个教程和解决方案,这些教程和解决方案适用于双指缩放,但不适用于 2 指旋转。我正在分享易于理解的最简单的教程,我想将其扩展为 2 指旋转。这是代码片段:

    public class MainActivity extends Activity {
    private ImageView mImageView;
    private Matrix mMatrix = new Matrix();
    private float mScale = 1f;
    private ScaleGestureDetector mScaleGestureDetector;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mImageView = (ImageView) findViewById(R.id.imageView);
        mScaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener());
    }

    public boolean onTouchEvent(MotionEvent ev) {
        mScaleGestureDetector.onTouchEvent(ev);
        return true;
    }

    private class ScaleListener extends ScaleGestureDetector.
            SimpleOnScaleGestureListener {
        @Override
        public boolean onScale(ScaleGestureDetector detector) {
            mScale *= detector.getScaleFactor();
            mScale …
Run Code Online (Sandbox Code Playgroud)

android multi-touch image-rotation pinchzoom android-studio

5
推荐指数
1
解决办法
7887
查看次数

ExifInterface构造函数引发IOExxception

在尝试使用文件路径初始化exif接口实例时,我很难弄清ExifInterface构造函数引发的异常。

更新 请根据要求查看下面的详细代码。

文件下载功能

public void downloadAndSaveFile(String url, String directoryId, String fileName) {
    HttpURLConnection conn = null;
    try {
        Log.d(TAG, "DownloadFileTask url : " + url);
        conn = getGETConnection(url);
        conn.setRequestProperty("Accept", "application/json");
        conn.setRequestProperty("Content-Type", "application/json");
        conn.setRequestProperty("Authorization", "Bearer " + MY_AUTH_TOKEN);
        conn.connect();
        File file = new File(FileTools.getCacheFileLocation(fileName, directoryId));
        FileOutputStream fileOutput = new FileOutputStream(file);
        InputStream inputStream = (InputStream) conn.getInputStream();
        byte[] buffer = new byte[1024 * 1024];
        int bufferLength = 0;
        while ((bufferLength = inputStream.read(buffer)) > 0) {
            fileOutput.write(buffer, 0, bufferLength);
        }
        fileOutput.close();
        inputStream.close();
        Log.d(TAG, …
Run Code Online (Sandbox Code Playgroud)

android image-rotation

5
推荐指数
1
解决办法
6112
查看次数

Firebase存储图像被旋转

在我的应用程序中,我提示用户捕获图像.用户相机活动从buttonClick开始,用户可以选择使用相机捕获图像.

此图像保存在用户手机上.然后将图像上传到firebase存储,一切正常.使用Samsung Note 8的一个用户的反馈是,当以纵向模式捕获图像时,他稍后在应用程序中以横向模式显示它.

我查看了firebase存储,发现图像以LANDSCAPE模式保存在存储中,即使用户以纵向模式捕获图像.

我想我必须将元数据传递给以纵向模式捕获图像的jpeg文件,以便firebase知道它实际上是纵向模式.

这是捕获图像的代码:

private void takePhoto() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        File photoFile = null;
        try {


            photoFile = createImageFile();


        } catch (IOException ex) {
            // Error occurred while creating the File

        }


        if (photoFile != null) {


            imageUri = FileProvider.getUriForFile(this, "com.example.android.fileprovider", photoFile);
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
            startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);

        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这是CreateImageFile的方法:

public File createImageFile() throws IOException {
    // Create an image file name
    String timeStamp = new SimpleDateFormat("yyyy.MM.dd_HH:mm:ss").format(new Date());

    String …
Run Code Online (Sandbox Code Playgroud)

android image-rotation firebase firebase-storage

5
推荐指数
1
解决办法
2066
查看次数