从设备的file.uri动态创建低分辨率缩略图,用于cordova项目中的图库图像(Dynamically creating low resolution thumbnails from a device's file.uri for gallery images in a cordova project)
我可能在这里不合适但我想在我尝试解决之前找出是否确实有这个问题的解决方案。
我在iOS上使用cordova并访问设备的图像库,获取照片的file.uri(根据phongap文档最少的内存饥饿方式),然后将其渲染为页面上大约50px x 50px的图像。
我遇到的问题是,一旦我将4张或更多张照片加载到页面上,性能开始受到影响,对其他表单元素的关注变得缓慢,并且有点“不稳定”。 我认为这与我显然在一个小盒子中渲染高分辨率图像这一事实有关,当你在一个页面上有多个高分辨率图像时,你会对设备的资源造成严重压力。 这是在iPhone 5上,我认为性能会更糟,仍然是4s和4。
有没有办法以编程方式创建图像的“低分辨率”版本,然后在我的页面上使用这些低分辨率图像? 从理论上讲,我可以访问图像及其位置,因此,为了提高性能,我是否可以动态转换/压缩/缩小这些图像,然后在完成实际图像文件的上传后丢弃这些缩略图/临时图像?
I may be off the mark here but I wanted to find out if there actually is a solution to this problem before I try and solve it.
I'm using cordova on iOS and accessing the device's image gallery, fetching a photo's file.uri (the least memory hungry way according to phongap docs) and then rendering this into a roughly 50px x 50px image on the page.
The problem I've run into is that once I have loaded 4 or more photos onto the page, the performance starts to suffer, focus on other form elements becomes slow, and somewhat 'jerky'. I believe that this has to do with the fact that I am obviously rendering a high resolution image in a tiny box and when you have multiple high res images on one page you put a serious strain on the device's resources. This is on an iPhone 5, I would imagine the performance to be worse still on a 4s and 4.
Is there a way to programatically create 'low res' versions of the image(s) and then use these low res images on my page? In theory I have access to the image and its location, so can I not convert/compress/downscale these on the fly for the purpose of improving performance and then ditch these thumbnails/temp images once any upload of the actual image files is complete?
原文:https://stackoverflow.com/questions/21184070
最满意答案
根据Java 文档文档,regexp与unicode不匹配:
默认情况下,不区分大小写的匹配假定仅匹配US-ASCII字符集中的字符
为了使你的代码工作,添加UNICODE_CASE标志:
Pattern pattern = Pattern.compile("^[а-я]+\\s[а-я]+\\s[а-я]+$", Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
According to Java documentation documentation regexp does not match unicode:
By default, case-insensitive matching assumes that only characters in the US-ASCII charset are being matched
In order to make your code working, add UNICODE_CASE flag:
Pattern pattern = Pattern.compile("^[а-я]+\\s[а-я]+\\s[а-я]+$", Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
相关问答
更多-
根据Java 文档文档,regexp与unicode不匹配: 默认情况下,不区分大小写的匹配假定仅匹配US-ASCII字符集中的字符 为了使你的代码工作,添加UNICODE_CASE标志: Pattern pattern = Pattern.compile("^[а-я]+\\s[а-я]+\\s[а-я]+$", Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); According to Java documentation documentat ...
-
是的,你需要抓住matcher.replaceAll()的结果: String result = matcher.replaceAll(" "); System.out.println(result); Yeah, you need to grab the result of matcher.replaceAll(): String result = matcher.replaceAll(" "); System.out.println(result);
-
使用Pattern.quote(...) : String s = "\\Q\\Q\\E\\Q\\E\\E"; String escaped = Pattern.quote(s); Use Pattern.quote(...): String s = "\\Q\\Q\\E\\Q\\E\\E"; String escaped = Pattern.quote(s);
-
正则表达式匹配Java(Regex matching Java)[2022-01-07]
这是一个与预期结果相符的复杂模式。 String test = "TeSTStringOne"; System.out.println( Arrays.toString( // | preceded by lowercase // | | followed by uppercase // | | | or // | ... -
Java正则表达式匹配(Java regex matching)[2022-09-25]
我会像这样使用String.replaceAll()方法: `String old =“一些字符串数据”; String new = old.replaceAll(“$([a-zA-Z0-9] +)”,“(\ 1)CONSTANT”); ` THE SOLUTION : while ((line = br.readLine()) != null) { if(line.contains("$")){ sb.append(line.re ... -
正则表达式允许在PHP中使用英文和俄文字符集[复制](Regex that allows English and Russian Character Sets in PHP [duplicate])[2022-07-07]
也许是因为你没有把它们放在同一个支架中? (另一个问题提到u国旗) '/^[a-z][a-z А-Яа-яЁё]*$/iu' Maybe because you didn't put them in the same bracket? (and the other question mentions the u flag) '/^[a-z][a-z А-Яа-яЁё]*$/iu' -
在RE2中,如果未指定re2.U标志, \w仅匹配ASCII字母: \w字符(≡ [0-9A-Za-z_] ) 因此[^\w]匹配西里尔字母。 因此,您需要使用re2.U标志。 由于你将re2.I和re2.U组合在一起,你需要在它们之间使用按位OR( | ): re2.compile(
, re2.I | re2.U) In RE2, \w only matches ASCII letters if you do not specify the re2.U flag: \w w ... -
使用posix字符类\p{L}表示“任何字母”: System.out.println("abcßè".matches("\\p{L}+")); // true Use the posix character class \p{L} for "any letter": System.out.println("abcßè".matches("\\p{L}+")); // true
-
您正在尝试在正则表达式中使用备用列表 ,而是使用字符类 ( "[\\baddAction\\b|\\bintentFilter\\b] )。对于字符类,其中的所有字符都单独匹配,而不是给定的序列。 您学习了单词边界 ,还需要了解分组的工作原理。 你有一个结构: 双字引号和括号中的 单词字符 + 单词 。 因此,您需要对第一个进行分组,最好使用非捕获组,并从word删除一些单词边界(在指定的上下文中是多余的): String rgx ="\\b(?:addAction|intentFilter)\\b\\s* ...
-
您可以使用负面预测 : "\\((?!789\\)).*?\\)" 说明: \\( Match a literal open parenthesis "(" (?! Start negative lookahead 789\\) Match literal "789)" ) End lookahead .*? Match any characters (non-greedy) \\) Match a literal close parenthesis ")" ...