问题描述
我正在制作用于图像发送和下载的聊天应用程序。我想在WhatsApp中做一些动画。那么,如何显示模糊的图像?我的图像是从服务器下载的。请帮助我。
I am making a Chat application for image sending and downloading. I want to do some animation like in WhatsApp. So, how to show the blurred image? My image is downloaded from server. Please help me.
推荐答案
将图像缩小到非常小的尺寸,例如8x8像素。将该数据发送到客户端。它不应超过 4 * 8 * 8
= 256 B或0.25 KB的大小,因此无论客户端的速度有多慢,将其发送到客户端都不会有问题连接速度是。
Scale the image down to a very small size like say 8x8 pixels. Send that data to the client. It should not be more than 4 * 8 * 8
= 256 B or 0.25 KB in size, so sending it to the client will not be a problem no matter how slow the client's connection speed is.
然后将接收的8x8图像缩放到预览框的分辨率(例如256x256)。如果预览框是 UIImageView
,则不需要对8x8图像进行上采样(请参阅下面的链接)。这种下采样和连续上采样图像会模糊图像。
Then scale the received 8x8 image to the resolution of the preview box (e.g. 256x256). You shouldn't need to upsample the 8x8 image if the preview box is a UIImageView
(see the link below). This downsampling and successive upsampling of an image "blurs" the image.
要了解如何在iOS中重新采样/重新缩放图像,请检查。我不是iOS开发人员,无法帮助您专门为iOS执行此任务。
To understand how you can resample/rescale an image in iOS, check this link. I am not an iOS developer and cannot help you much in performing this task specifically for iOS.
这篇关于如何在ios下载之前显示模糊图像(如在whatsapp中)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!