Mercurial > dwindows
comparison android/DWindows.kt @ 2529:060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
Clean up some clang-tidy warnings reported by Android Studio.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 10 May 2021 20:06:50 +0000 |
parents | 03f6870bcfcc |
children | b9923432cb1f |
comparison
equal
deleted
inserted
replaced
2528:03f6870bcfcc | 2529:060fdb2d807d |
---|---|
1735 } | 1735 } |
1736 } | 1736 } |
1737 } | 1737 } |
1738 } | 1738 } |
1739 | 1739 |
1740 fun pixmapNew(width: Int, height: Int, filename: String?, data: ByteArray?, length: Int, resID: Int): Bitmap? | |
1741 { | |
1742 var pixmap: Bitmap? = null | |
1743 | |
1744 waitOnUiThread { | |
1745 if(width > 0 && height > 0) { | |
1746 pixmap = Bitmap.createBitmap(null, width, height, Bitmap.Config.ARGB_8888) | |
1747 } else if(resID != 0) { | |
1748 pixmap = BitmapFactory.decodeResource(resources, resID); | |
1749 } else if(filename != null) { | |
1750 // Try to load the image, and protect against exceptions | |
1751 try { | |
1752 val f = File(filename) | |
1753 pixmap = BitmapFactory.decodeStream(FileInputStream(f)) | |
1754 } catch (e: FileNotFoundException) { | |
1755 } | |
1756 } else if(data != null) { | |
1757 pixmap = BitmapFactory.decodeByteArray(data, 0, length) | |
1758 } | |
1759 } | |
1760 return pixmap | |
1761 } | |
1762 | |
1763 fun pixmapGetDimensions(pixmap: Bitmap): Long | |
1764 { | |
1765 var dimensions: Long = 0 | |
1766 | |
1767 waitOnUiThread { | |
1768 dimensions = pixmap.width.toLong() or (pixmap.height.toLong() shl 32) | |
1769 } | |
1770 return dimensions | |
1771 } | |
1772 | |
1740 fun timerConnect(interval: Long, sigfunc: Long, data: Long): Timer | 1773 fun timerConnect(interval: Long, sigfunc: Long, data: Long): Timer |
1741 { | 1774 { |
1742 // creating timer task, timer | 1775 // creating timer task, timer |
1743 val t = Timer() | 1776 val t = Timer() |
1744 val tt: TimerTask = object : TimerTask() { | 1777 val tt: TimerTask = object : TimerTask() { |