ElectronJS:如何旋转电子中的图像?

时间:2018-08-31 01:59:28

标签: electron

我看到nativeImage允许进行一些调整大小和其他操作,但是我需要使用户能够将图像旋转90度。电子应用程序有可能吗?

2 个答案:

答案 0 :(得分:0)

// activeTextView was defined inside textView if activeTextView != nil { // now you can access it via textview.superview? if let origin = activeTextView.superview?.frame.origin, let parentFrame = activeTextView.superview?.frame { if !aRect.contains(origin) { scrollView.scrollRectToVisible(parentFrame, animated:true) } } } 公开了nativeImage,您可以用它来处理原始像素数据。

旋转图像就像移动阵列的每个像素一样简单。基本上是getBitmap

答案 1 :(得分:0)

有了Electron,您几乎可以使用npm repository中的所有node.js库。例如,您可以使用imagejs旋转位图。

注意:我还没有真正测试过:

const ImageJS = require("imagejs");

const buf = nativeImage.getBitmap();
const { width, height } = nativeImage.getSize();

const bitmap = new ImageJS.Bitmap({
    width: width,
    height: height,
    data: buf
});

const rotated = bitmap.rotate({degrees: 90, fit: "crop"});