试图实现图像的徒手裁剪,所以我能够在图像上绘图.但它超出了位图区域.我只想限制用户只能在位图区域内绘制,检查下面的屏幕截图.
我正在尝试实现像Photoshop套索工具这样的功能.
它在视图区域外绘制,产生不正确的输出.

产量

码@
的onDraw
public void onDraw(Canvas canvas) {
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
canvas.drawBitmap(bitmap, rect, rect, null);
// RectF r = new RectF();
// Matrix matrix = new Matrix();
// matrix.mapRect(r);
// Log.i(TAG, "Rect " + r.left + " " + r.top + " " + r.right + " " +
// r.bottom + " ");
// canvas.clipRect(r.left, r.top, r.right, r.bottom);
Path path = new Path();
boolean first = true;
for …Run Code Online (Sandbox Code Playgroud) 我试图使用以下代码将我的包中的文件复制到iOS中的文档目录.
let bundlePath = NSBundle.mainBundle().pathForResource("information", ofType: ".png")
print(bundlePath, "\n") //prints the correct path
let destPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first!
let fileManager = NSFileManager.defaultManager()
let fullDestPath = NSURL(fileURLWithPath: destPath).URLByAppendingPathComponent("information.png")
let fullDestPathString = String(fullDestPath)
print(fileManager.fileExistsAtPath(bundlePath!)) // prints true
do{
try fileManager.copyItemAtPath(bundlePath!, toPath: fullDestPathString)
}catch{
print("\n")
print(error)
}
Run Code Online (Sandbox Code Playgroud)
错误域= NSCocoaErrorDomain代码= 4"文件"information.png"不存在." UserInfo = {NSSourceFilePathErrorKey =/Users/macbookpro/Library/Developer/CoreSimulator/Devices/E58CA1C6-C6F1-4D72-9572-3925675E78A5/data/Containers/Bundle/Application/EFA83E02-5F24-4BB3-B32A-7E755081A730/AutoLayout tuts.app /information.png,NSUserStringVariant =(Copy),NSDestinationFilePath = file:/// Users/macbookpro/Library/Developer/CoreSimulator/Devices/E58CA1C6-C6F1-4D72-9572-3925675E78A5/data/Containers/Data/Application/86A1BDD5- FAF2-486E-85A9-CF72A547C6CD/Documents/information.png,NSFilePath =/Users/macbookpro/Library/Developer/CoreSimulator/Devices/E58CA1C6-C6F1-4D72-9572-3925675E78A5/data/Containers/Bundle/Application/EFA83E02-5F24 -4BB3-B32A-7E755081A730/AutoLayout tuts.app/information.png,NSUnderlyingError = 0x7fb53251cd80 {Error Domain = NSPOSIXErrorDomain Code = 2"No such file or directory"}}
根据fileManager.fileExistsAtPath()该文件确实存在.我究竟做错了什么?