분류 전체보기(112)
-
Protocol
http://seorenn.blogspot.com/2014/06/swift-protocols.html Swift - 프로토콜(Protocols) iOS 및 macOS 용 앱 개발, Emacs, Vim, Python 위주로 다루는 Seorenn 개인 블로그 seorenn.blogspot.com https://dongkyprogramming.tistory.com/11 Swift 프로토콜(protocol)과 Java 인터페이스(interface) 차이 Swift 언어를 공부하면서 Swift는 OOP(Object Oriented Programming)이 아닌 Protocol Oriented Programming이란 내용을 듣고 Protocol을 공부하면서 자바의 Interface와 거의 똑같은 거 아닌가? 하는..
2019.12.30 -
file.copyTo
val file = File(path) if(file.path.startsWith("file:/") or file.path.startsWith("file:///")){ FileOutputStream(File(file.absolutePath, file.name)).use { out -> assets.open(file.name).use { it.copyTo(out) } } }else{ file.copyTo(File(file.absolutePath, file.name), true) }
2019.12.20 -
Bitmap to File
fun bitmapToFile(bitmap: Bitmap, path: String): File{ var file = File(path) var out: OutputStream? = null try{ file.createNewFile() out = FileOutputStream(file) bitmap.compress(Bitmap.CompressFormat.JPEG, 80, out) }finally{ out?.close() } return file } https://smartstore.naver.com/byrollin? 바이롤린 : 네이버쇼핑 스마트스토어 언제나 함께해요 smartstore.naver.com
2019.12.20 -
zip, unzip
fun unZip(zipFile: File, targetPath: String) { val zip = ZipFile(zipFile, "euc-kr") // UTF-8 zip.entries.forEach { if (!it.isDirectory) BufferedInputStream(zip.getInputStream(it)).use { bis -> File(targetPath, it.name).outputStream().buffered(1024).use { bis.copyTo(it) } } } } fun zip(path: String){ val folderToZip = File(path) var out: ZipOutputStream? = null try { out = ZipOutputStream( Buffer..
2019.12.20 -
Bitmap in putExtra
// putExtra Activity val bimap = BitmapFactory.decodeFile(path) // example val stream = ByteArrayOutputStream() bitmap.compress(Bitmap.CompressFormat.JPEG, 80, stream) val byteArray = stream.toByteArray() startActivityForResult(Intent(this, TestActivity::class.java).apply { putExtra("bitmap", byteArray) }, 100) // TestActivity private var mBitmap: Bitmap? = null onCreate(){ intent.let { it.getBy..
2019.12.20 -
BitmapFromAsset
fun getBitmapFromAsset(context: Context, name: String): Bitmap?{ val assetManager = context.assets as AssetManager var inputStream: InputStream try { inputStream = assetManager.open(name) return BitmapFactory.decodeStream(inputStream) } catch (e: IOException) { e.printStackTrace() return null } } // ex) name = "test.jpg" (ok) // name = "file:///android_asset/test.jpg"(not okay) getBitmapFromAsse..
2019.12.20