在我的iPhone应用程序中,我用相机拍照,然后我想将其调整为290*390像素.我正在使用此方法调整图像大小:
UIImage *newImage = [image _imageScaledToSize:CGSizeMake(290, 390)
interpolationQuality:1];
Run Code Online (Sandbox Code Playgroud)
它工作得很好,但它是一个未记录的功能,所以我不能再使用iPhone OS4了.
那么...调整UIImage大小的最简单方法是什么?
还有另外一个关于这个问题,我试过了.但是有一个问题:textarea
如果删除内容,则不会缩小.我找不到任何方法将它缩小到正确的大小 - clientHeight
值返回为完整的大小,而textarea
不是其内容.
该页面的代码如下:
function FitToContent(id, maxHeight)
{
var text = id && id.style ? id : document.getElementById(id);
if ( !text )
return;
var adjustedHeight = text.clientHeight;
if ( !maxHeight || maxHeight > adjustedHeight )
{
adjustedHeight = Math.max(text.scrollHeight, adjustedHeight);
if ( maxHeight )
adjustedHeight = Math.min(maxHeight, adjustedHeight);
if ( adjustedHeight > text.clientHeight )
text.style.height = adjustedHeight + "px";
}
}
window.onload = function() {
document.getElementById("ta").onkeyup = function() {
FitToContent( this, 500 ) …
Run Code Online (Sandbox Code Playgroud) 如何使用jQuery确定浏览器视口的大小,并在页面调整大小时重新检测?我需要在这个空间中建立一个IFRAME大小(每个边缘都有一点).
对于那些不知道的人,浏览器视口不是文档/页面的大小.它是滚动前窗口的可见大小.
在调整浏览器窗口大小时,如何让React重新渲染视图?
我有一些块,我想在页面上单独布局,但我也希望它们在浏览器窗口更改时更新.最终结果将是Ben Holland的 Pinterest布局,但使用React编写的不仅仅是jQuery.我还有一段路要走.
这是我的应用程序:
var MyApp = React.createClass({
//does the http get from the server
loadBlocksFromServer: function() {
$.ajax({
url: this.props.url,
dataType: 'json',
mimeType: 'textPlain',
success: function(data) {
this.setState({data: data.events});
}.bind(this)
});
},
getInitialState: function() {
return {data: []};
},
componentWillMount: function() {
this.loadBlocksFromServer();
},
render: function() {
return (
<div>
<Blocks data={this.state.data}/>
</div>
);
}
});
React.renderComponent(
<MyApp url="url_here"/>,
document.getElementById('view')
)
Run Code Online (Sandbox Code Playgroud)
然后我有了Block
组件(相当于Pin
上面Pinterest示例中的一个):
var Block = React.createClass({
render: function() {
return ( …
Run Code Online (Sandbox Code Playgroud) 如Size
,Width
和Height
是Get()
的性质System.Drawing.Image
;
如何在C#中运行时调整Image对象的大小?
现在,我只是创建一个新的Image
使用:
// objImage is the original Image
Bitmap objBitmap = new Bitmap(objImage, new Size(227, 171));
Run Code Online (Sandbox Code Playgroud) 在Firefox,WebKit和Internet Explorer中使用的窗口调整大小事件的正确(现代)方法是什么?
你可以打开/关闭两个滚动条吗?
所以我目前使用的东西如下:
$(window).resize(function(){resizedw();});
Run Code Online (Sandbox Code Playgroud)
但是在调整大小过程的过程中会多次调用它.是否可以在事件结束时捕获事件?
我在一个文件中有一个大位图(比如3888x2592).现在,我想将该位图的大小调整为800x533并将其保存到另一个文件中.我通常会通过调用Bitmap.createBitmap
方法来缩放位图,但它需要一个源位图作为第一个参数,我无法提供,因为将原始图像加载到Bitmap对象当然会超出内存(例如,请参见此处).
我也无法读取位图,例如,BitmapFactory.decodeFile(file, options)
提供a BitmapFactory.Options.inSampleSize
,因为我想将其调整为精确的宽度和高度.使用inSampleSize
会将位图的大小调整为972x648(如果我使用inSampleSize=4
)或778x518(如果我使用inSampleSize=5
,它甚至不是2的幂).
我还想避免使用inSampleSize在第一步中使用例如972x648读取图像,然后在第二步中将其大小调整为800x533,因为与直接调整原始图像大小相比,质量会很差.
总结我的问题:是否有办法读取10MP或更高的大图像文件并将其保存到新的图像文件,调整大小到特定的新宽度和高度,而不会得到OutOfMemory异常?
我也尝试BitmapFactory.decodeFile(file, options)
手动将Options.outHeight和Options.outWidth值设置为800和533,但它不起作用.
我正在编写一个自定义视图,从RelativeLayout扩展,我想以编程方式调整它,我该怎么办?
自定义视图类是这样的:
public ActiveSlideView(Context context, AttributeSet attr){
super(context, attr);
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if(inflater != null){
inflater.inflate(R.layout.active_slide, this);
}
Run Code Online (Sandbox Code Playgroud) 我想使用OpenCV2.0和Python2.6来显示已调整大小的图像.我在http://opencv.willowgarage.com/documentation/python/cookbook.html上使用并采用了这个例子,但遗憾的是这段代码适用于OpenCV2.1,似乎没有在2.0上运行.这是我的代码:
import os, glob
import cv
ulpath = "exampleshq/"
for infile in glob.glob( os.path.join(ulpath, "*.jpg") ):
im = cv.LoadImage(infile)
thumbnail = cv.CreateMat(im.rows/10, im.cols/10, cv.CV_8UC3)
cv.Resize(im, thumbnail)
cv.NamedWindow(infile)
cv.ShowImage(infile, thumbnail)
cv.WaitKey(0)
cv.DestroyWindow(name)
Run Code Online (Sandbox Code Playgroud)
既然我不能用
cv.LoadImageM
Run Code Online (Sandbox Code Playgroud)
我用了
cv.LoadImage
Run Code Online (Sandbox Code Playgroud)
相反,这在其他应用程序中没有问题.然而,cv.iplimage没有属性行,列或大小.任何人都可以给我一个提示,如何解决这个问题?谢谢.