当前位置: 首页 > news >正文

哪些网站可以做百科来源2017年网站建设工作总结

哪些网站可以做百科来源,2017年网站建设工作总结,北京网站平台建设,wordpress插件 幻灯片Bitmap缩放和平移 加载一张Bitmap可能为宽高相同的正方形#xff0c;也可能为宽高不同的矩形缩放方向可以为中心缩放#xff0c;左上角缩放#xff0c;右上角缩放#xff0c;左下角缩放#xff0c;右下角缩放Bitmap中心缩放#xff0c;包含了缩放和平移两个操作#xf…Bitmap缩放和平移 加载一张Bitmap可能为宽高相同的正方形也可能为宽高不同的矩形缩放方向可以为中心缩放左上角缩放右上角缩放左下角缩放右下角缩放Bitmap中心缩放包含了缩放和平移两个操作不可拆开Bitmap其余四个方向的缩放可以单独缩放不带平移也可以缩放带平移 XML文件 ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationverticalcom.yang.app.MyRelativeLayoutandroid:idid/real_rlandroid:layout_widthmatch_parentandroid:layout_height0dpandroid:layout_weight1android:layout_marginTop30dpandroid:layout_marginBottom30dpandroid:layout_marginLeft30dpandroid:layout_marginRight30dpandroid:backgroundcolor/graycom.yang.app.MyImageViewandroid:idid/real_ivandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:layout_marginTop30dpandroid:layout_marginBottom30dpandroid:layout_marginLeft30dpandroid:layout_marginRight30dp //com.yang.app.MyRelativeLayoutImageViewandroid:layout_widthmatch_parentandroid:layout_height200dpandroid:layout_weight0android:background#00ff00 / /LinearLayoutActivity代码 const val TAG Yang class MainActivity : AppCompatActivity() {var mRealView : MyImageView ? nullvar mRelativeLayout : MyRelativeLayout ? nullvar tempBitmap : Bitmap ? nullvar mHandler Handler(Looper.getMainLooper())var screenWidth 0var screenHeight 0var srcRect RectF()var destRect RectF()override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)mRealView findViewById(R.id.real_iv)mRelativeLayout findViewById(R.id.real_rl)// 屏幕宽高的一半作为临时RectF, 用于压缩BitmapscreenWidth resources.displayMetrics.widthPixelsscreenHeight resources.displayMetrics.heightPixelsval tempRect RectF(0f, 0f, screenWidth.toFloat() / 2, screenHeight.toFloat() / 2)CoroutineScope(Dispatchers.IO).launch {tempBitmap getBitmap(resources, tempRect, R.drawable.fake)withContext(Dispatchers.Main) {mRelativeLayout?.post {// 获取初始区域的RectFsrcRect.set(0f,0f,mRelativeLayout?.width?.toFloat()!!,mRelativeLayout?.height?.toFloat()!!)// 获取结束区域的RectFmRelativeLayout?.forEach { childView -if (childView is MyImageView) {destRect.set(0f,0f,childView.width.toFloat(),childView.height.toFloat())}}scaleRectFun(tempBitmap, srcRect, destRect)}}}}fun scaleRectFun(tempBitmap: Bitmap?, srcRect : RectF, destRect: RectF){tempBitmap?.let { bitmap-mRelativeLayout?.setBitmap(bitmap)val animator ValueAnimator.ofFloat(0f, 1f)animator.duration 5000Lanimator.interpolator DecelerateInterpolator()animator.addUpdateListener {val value it.animatedValue as Float// 中心缩放mRelativeLayout?.setDestRectCenterWithTranslate(srcRect, destRect, value)// 左上角不带平移缩放// mRelativeLayout?.setDestRectLeftTopNoTranslate(srcRect, destRect, value)// 左上角平移缩放// mRelativeLayout?.setDestRectLeftTopWithTranslate(srcRect, destRect, value)// 右上角不带平移缩放// mRelativeLayout?.setDestRectRightTopNoTranslate(srcRect, destRect, value)// 右上角平移缩放// mRelativeLayout?.setDestRectRightTopWithTranslate(srcRect, destRect, value)// 左下角不带平移缩放// mRelativeLayout?.setDestRectLeftBottomNoTranslate(srcRect, destRect, value)// 左下角平移缩放// mRelativeLayout?.setDestRectLeftBottomWithTranslate(srcRect, destRect, value)// 右下角不带平移缩放// mRelativeLayout?.setDestRectRightBottomNoTranslate(srcRect, destRect, value)// 右下角平移缩放// mRelativeLayout?.setDestRectRightBottomWithTranslate(srcRect, destRect, value)}animator.start()}} } fun getBitmap(resources : Resources, destRect : RectF, imageId: Int): Bitmap? {var imageWidth -1var imageHeight -1val preOption BitmapFactory.Options().apply {// 只获取图片的宽高inJustDecodeBounds trueBitmapFactory.decodeResource(resources, imageId, this)}imageWidth preOption.outWidthimageHeight preOption.outHeight// 计算缩放比例val scaleMatrix Matrix()// 确定未缩放Bitmap的RectFvar srcRect RectF(0f, 0f, imageWidth.toFloat(), imageHeight.toFloat())// 通过目标RectF, 确定缩放数值存储在scaleMatrix中scaleMatrix.setRectToRect(srcRect, destRect, Matrix.ScaleToFit.CENTER)// 缩放数值再映射到原始Bitmap上得到缩放后的RectFscaleMatrix.mapRect(srcRect)val finalOption BitmapFactory.Options().apply {if (imageHeight 0 imageWidth 0) {inPreferredConfig Bitmap.Config.RGB_565inSampleSize calculateInSampleSize(imageWidth,imageHeight,srcRect.width().toInt(),srcRect.height().toInt())}}return BitmapFactory.decodeResource(resources, imageId, finalOption) }fun calculateInSampleSize(fromWidth: Int, fromHeight: Int, toWidth: Int, toHeight: Int): Int {var bitmapWidth fromWidthvar bitmapHeight fromHeightif (fromWidth toWidth|| fromHeight toHeight) {var inSampleSize 2// 计算最大的inSampleSize值该值是2的幂并保持原始宽高大于目标宽高while (bitmapWidth toWidth bitmapHeight toHeight) {bitmapWidth / 2bitmapHeight / 2inSampleSize * 2}return inSampleSize}return 1 }自定义ViewGroup和View代码 class MyImageView JvmOverloads constructor(context: Context, attrs: AttributeSet? null, defStyleAttr: Int 0 ) : AppCompatImageView(context, attrs, defStyleAttr)class MyRelativeLayout JvmOverloads constructor(context: Context, attrs: AttributeSet? null, defStyleAttr: Int 0 ) : RelativeLayout(context, attrs, defStyleAttr) {var mBitmap : Bitmap ? nullvar mScaleMatrix Matrix()var mDestRect RectF()fun setBitmap(bitmap: Bitmap?) {mBitmap bitmap}override fun onDraw(canvas: Canvas?) {super.onDraw(canvas)mBitmap?.let {canvas?.drawBitmap(it, mScaleMatrix, Paint().apply {isAntiAlias true})}} }中心缩放 ValueAnimator动画的初始值为0开始区域为外层MyRelativeLayout区域结束区域为内层MyImageView区域缩放区域在这两个区域大小之间变化缩放比例取决于当前缩放区域mDestRect和Bitmap宽高的最小宽高比 fun setDestRectCenterWithTranslate(srcRect: RectF, destRect: RectF, value : Float) {mDestRect RectF(srcRect.left (destRect.left - srcRect.left) * value,srcRect.top (destRect.top - srcRect.top) * value,srcRect.right (destRect.right - srcRect.right) * value,srcRect.bottom (destRect.bottom - srcRect.bottom) * value)val scale Math.min(mDestRect.width() / mBitmap?.width!!, mDestRect.height() / mBitmap!!.height)val dx (srcRect.width() - mBitmap?.width!! * scale) / 2val dy (srcRect.height() - mBitmap?.height!! * scale) / 2mScaleMatrix.reset()mScaleMatrix.postScale(scale, scale)mScaleMatrix.postTranslate(dx, dy)invalidate() }中心缩放效果图 左上角缩放 左上角不带平移缩放 fun setDestRectLeftTopNoTranslate(srcRect: RectF, destRect: RectF, value : Float) {mDestRect RectF(srcRect.left (destRect.left - srcRect.left) * value,srcRect.top (destRect.top - srcRect.top) * value,srcRect.right (destRect.right - srcRect.right) * value,srcRect.bottom (destRect.bottom - srcRect.bottom) * value)val scale Math.min(mDestRect.width() / mBitmap?.width!!, mDestRect.height() / mBitmap!!.height)mScaleMatrix.setScale(scale, scale)invalidate() }左上角不带平移缩放效果图 左上角带平移缩放 fun setDestRectLeftTopWithTranslate(srcRect: RectF, destRect: RectF, value : Float) {mDestRect RectF(srcRect.left (destRect.left - srcRect.left) * value,srcRect.top (destRect.top - srcRect.top) * value,srcRect.right (destRect.right - srcRect.right) * value,srcRect.bottom (destRect.bottom - srcRect.bottom) * value)val scale Math.min(mDestRect.width() / mBitmap?.width!!, mDestRect.height() / mBitmap!!.height)val dx ((srcRect.width() - destRect.width())/2) * value (destRect.left - srcRect.left) * valueval dy ((srcRect.height() - destRect.height())/2) * value (destRect.top - srcRect.top) * valuemScaleMatrix.reset()mScaleMatrix.postScale(scale, scale)mScaleMatrix.postTranslate(dx, dy)invalidate() }左上角带平移缩放效果图 右上角缩放 右上角不带平移缩放 fun setDestRectRightTopNoTranslate(srcRect: RectF, destRect: RectF, value : Float) {mDestRect RectF(srcRect.left (destRect.left - srcRect.left) * value,srcRect.top (destRect.top - srcRect.top) * value,srcRect.right (destRect.right - srcRect.right) * value,srcRect.bottom (destRect.bottom - srcRect.bottom) * value)val scale Math.min(mDestRect.width() / mBitmap?.width!!, mDestRect.height() / mBitmap!!.height)val dx srcRect.width() - mBitmap!!.width * scaleval dy 0fmScaleMatrix.reset()mScaleMatrix.postScale(scale, scale)mScaleMatrix.postTranslate(dx, dy)invalidate() }右上角不带平移缩放效果图 右上角带平移缩放 fun setDestRectRightTopWithTranslate(srcRect: RectF, destRect: RectF, value : Float) {mDestRect RectF(srcRect.left (destRect.left - srcRect.left) * value,srcRect.top (destRect.top - srcRect.top) * value,srcRect.right (destRect.right - srcRect.right) * value,srcRect.bottom (destRect.bottom - srcRect.bottom) * value)val scale Math.min(mDestRect.width() / mBitmap?.width!!, mDestRect.height() / mBitmap!!.height)val dx ((srcRect.width() - destRect.width())/2) * value (destRect.left - srcRect.left) * valueval dy ((srcRect.height() - destRect.height())/2) * value (destRect.top - srcRect.top) * valuemScaleMatrix.reset()mScaleMatrix.postScale(scale, scale)mScaleMatrix.postTranslate(dx, dy)invalidate() }右上角不带平移缩放效果图 左下角缩放 左下角不带平移缩放 fun setDestRectLeftBottomNoTranslate(srcRect: RectF, destRect: RectF, value : Float) {mDestRect RectF(srcRect.left (destRect.left - srcRect.left) * value,srcRect.top (destRect.top - srcRect.top) * value,srcRect.right (destRect.right - srcRect.right) * value,srcRect.bottom (destRect.bottom - srcRect.bottom) * value)val scale Math.min(mDestRect.width() / mBitmap?.width!!, mDestRect.height() / mBitmap!!.height)val dx 0fval dy srcRect.height() - mBitmap?.height!! * scalemScaleMatrix.reset()mScaleMatrix.postScale(scale, scale)mScaleMatrix.postTranslate(dx, dy)invalidate() }左下角不带平移缩放效果图 左下角平移缩放 fun setDestRectLeftBottomWithTranslate(srcRect: RectF, destRect: RectF, value : Float) {mDestRect RectF(srcRect.left (destRect.left - srcRect.left) * value,srcRect.top (destRect.top - srcRect.top) * value,srcRect.right (destRect.right - srcRect.right) * value,srcRect.bottom (destRect.bottom - srcRect.bottom) * value)val scale Math.min(mDestRect.width() / mBitmap?.width!!, mDestRect.height() / mBitmap!!.height)val dx ((srcRect.width() - destRect.width())/2 )* valueval dy ((srcRect.height() - destRect.height())/2 )* value (destRect.bottom - srcRect.bottom) * value (srcRect.height()- mBitmap?.height!! * scale)mScaleMatrix.reset()mScaleMatrix.postScale(scale, scale)mScaleMatrix.postTranslate(dx, dy)invalidate() }左下角平移缩放效果图 右下角缩放 右下角不带平移缩放 fun setDestRectRightBottomNoTranslate(srcRect: RectF, destRect: RectF, value : Float) {mDestRect RectF(srcRect.left (destRect.left - srcRect.left) * value,srcRect.top (destRect.top - srcRect.top) * value,srcRect.right (destRect.right - srcRect.right) * value,srcRect.bottom (destRect.bottom - srcRect.bottom) * value)val scale Math.min(mDestRect.width() / mBitmap?.width!!, mDestRect.height() / mBitmap!!.height)val dx srcRect.width() - mBitmap!!.width * scaleval dy srcRect.height() - mBitmap?.height!! * scalemScaleMatrix.reset()mScaleMatrix.postScale(scale, scale)mScaleMatrix.postTranslate(dx, dy)invalidate() }右下角不带平移缩放效果图 右下角平移缩放 fun setDestRectRightBottomWithTranslate(srcRect: RectF, destRect: RectF, value : Float) {mDestRect RectF(srcRect.left (destRect.left - srcRect.left) * value,srcRect.top (destRect.top - srcRect.top) * value,srcRect.right (destRect.right - srcRect.right) * value,srcRect.bottom (destRect.bottom - srcRect.bottom) * value)val scale Math.min(mDestRect.width() / mBitmap?.width!!, mDestRect.height() / mBitmap!!.height)val dx ((srcRect.width() - destRect.width())/2 )* valueval dy ((srcRect.height() - destRect.height())/2 )* value (destRect.bottom - srcRect.bottom) * value (srcRect.height()- mBitmap?.height!! * scale)mScaleMatrix.reset()mScaleMatrix.postScale(scale, scale)mScaleMatrix.postTranslate(dx, dy)invalidate() }右下角平移缩放效果图
http://www.dnsts.com.cn/news/37940.html

相关文章:

  • 备案网站多长时间网站开发的就业前景
  • 网站建设维护费摊销做网站游戏总结的例文
  • 网站建设要托管服务器长沙注册公司可以买房吗
  • 汕头h5模板建站网站建设是啥
  • 网站建设需要多少钱费用win2003 wordpress 安装
  • 阜蒙县建设小学校官方网站佛山网络推广seo
  • 网站开发 c展厅展示公司
  • 哪里做网站比较稳定缘魁网站建设
  • 诚聘php网站开发师合肥做兼职网站设计
  • 济南市高新技术官方网站开发区给钱做h事都行的网站名
  • 开源网站源码下载用wordpress二级菜单导航栏
  • 模仿网站页面违法吗中国会出兵吗
  • 婚庆网站建设必要性合肥公司注册地址
  • 买卖信息网站上饶网站建设srsem
  • 卡片形式的网站昌大建设集团是哪里的
  • 网站大全app下载小制作小发明手工初中
  • 百度收录网站中文称Wordpress网站删除多余主题
  • 马鞍山做网站的公司手机在线建网站
  • 杭州四喜做网站建设么科技公司网站首页
  • 企业网站源码怎么用wordpress防爆破插件
  • 网站域名实名认证官网好网站建设公司昆明
  • 公司设计网站需要注意哪些壹舍设计公司
  • 百度网站怎么提升排名阿里云可以建设多个网站
  • php 视频播放网站开发陕西住房和城乡建设厅中心网站
  • dedecms建手机网站流程网站开发课程建议
  • html完整网站开发wordpress 根分类
  • 一个做问卷调查的网站好网站是专门对生活中的一些所谓常识做辟谣的
  • 像淘宝购物网站建设需要哪些专业人员做网站项目收获
  • 国外一个做同人动漫的网站企业年报申报入口官网
  • 如何建立国外网站wordpress主题ux