标签: resize

在Internet Explorer中触发window.resize事件

如您所知,在Internet Explorer中,当页面上的任何元素调整大小时,会触发window.resize事件.通过分配/更改其高度或样式属性,通过简单地向其添加子元素或其他任何内容来调整页面元素的大小也无关紧要 - 即使元素大小调整不影响视口本身的尺寸.

在我的应用程序中,这导致了一个讨厌的递归,因为在我的window.resize处理程序中我正在调整一些<li>元素,这反过来会重新触发window.resize等.再次,这只是IE中的一个问题.

是否有任何方法可以阻止window.resize在IE中触发以响应正在调整大小的页面上的元素?

我还应该提到我正在使用jQuery.

javascript jquery internet-explorer resize javascript-events

75
推荐指数
5
解决办法
6万
查看次数

什么是最好的图像缩小算法(质量方面)?

我想找出哪种算法最适合用于缩小光栅图片的尺寸.最好的我指的是给出最好看结果的那个.我知道bicubic,但还有更好的东西吗?例如,我从一些人那里听说Adobe Lightroom有一些专有算法,它产生的结果比我使用的标准双三次更好.不幸的是,我想在我的软件中自己使用这个算法,因此Adobe小心谨慎的商业秘密是行不通的.

添加:

我检查了Paint.NET,令我惊讶的是,在缩小图片时,Super Sampling似乎比bicubic更好.这让我想知道插值算法是否可行.

它还让我想起了我自己"发明"但从未实现过的算法.我想它也有一个名字(因为这个琐碎的东西不能仅仅是我的想法),但我在流行的那些中找不到它.超级采样是最接近的.

这个想法是这样的 - 对于目标图片中的每个像素,计算它在源图片中的位置.它可能会覆盖一个或多个其他像素.然后可以计算这些像素的面积和颜色.然后,为了获得目标像素的颜色,可以简单地计算这些颜色的平均值,将它们的区域添加为"权重".因此,如果目标像素覆盖1/3的黄色源像素和1/4的绿色源像素,我会得到(1/3*黄色+ 1/4*绿色)/(1/3 + 1/4).

这自然是计算密集型的,但它应该尽可能接近理想,不是吗?

这个算法有名字吗?

algorithm resize image

71
推荐指数
4
解决办法
8万
查看次数

Android中ImageView的最大宽度和高度

所以我有一个ImageView设置

android:maxHeight="100px"
android:maxWidth="250px"
android:minHeight="100px"
android:minWidth="250px"
android:scaleType="centerInside"
Run Code Online (Sandbox Code Playgroud)

此图像视图用于显示从图库或相机获取的图片.在这两种情况下,图像都不会调整大小以适应图像视图,它只是根据需要拉伸其空间.

知道怎么让它留在那些界限内吗?

<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)

<EditText
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:id="@+id/txtDescription"
    android:layout_below="@+id/txtSubject"
    android:inputType="textMultiLine"
    android:height="80px"
    android:hint="@string/description"></EditText>

<EditText
    android:layout_height="wrap_content"
    android:layout_below="@+id/txtDescription"
    android:layout_width="fill_parent"
    android:id="@+id/txtMorada"
    android:hint="@string/address" />

<ImageButton
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:layout_below="@+id/txtMorada"
    android:id="@+id/btGPS"
    android:layout_alignParentLeft="true"
    android:src="@drawable/ic_menu_compass"></ImageButton>

<ImageView
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:layout_below="@+id/btGPS"
    android:layout_marginTop="25px"
    android:id="@+id/imgPoint"
    android:src="@drawable/google_logo_small"
    android:maxHeight="100px"
    android:maxWidth="250px"
    android:minHeight="100px"
    android:minWidth="250px"
    android:scaleType="centerInside"></ImageView>

<ImageButton
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:layout_toRightOf="@+id/imgPoint"
    android:id="@+id/btGallery"
    android:layout_below="@+id/btCamera"
    android:src="@drawable/ic_menu_gallery"
    android:layout_alignParentRight="true"></ImageButton>

<Button
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:layout_marginTop="10px"
    android:id="@+id/btSubmit"
    android:layout_below="@+id/btGallery"
    android:text="@string/submit"></Button>

<ImageButton
    android:layout_height="wrap_content"
    android:id="@+id/btMap"
    android:layout_below="@+id/txtMorada"
    android:layout_width="wrap_content"
    android:layout_alignParentRight="true"
    android:src="@drawable/ic_menu_mapmode"></ImageButton>

<TextView
    android:layout_below="@+id/txtMorada"
    android:layout_width="wrap_content"
    android:layout_toLeftOf="@+id/btMap"
    android:layout_height="wrap_content"
    android:id="@+id/lblNewPointLatitude"
    android:text="Latitude"></TextView>

<TextView
    android:layout_width="wrap_content"
    android:layout_toLeftOf="@+id/btMap"
    android:layout_height="wrap_content"
    android:id="@+id/lblNewPointLongitude"
    android:layout_below="@+id/lblNewPointLatitude" …
Run Code Online (Sandbox Code Playgroud)

android resize stretch imageview android-imageview

71
推荐指数
3
解决办法
7万
查看次数

用PHP合并两个图像

我正在尝试将两个图像与PHP合并在一起.

例如......我将如何将图像置于图像2之上或合并为基本PHP?我尝试过像水印这样的东西,但它似乎没有用.

图一

替代文字

图像二

替代文字

......让它变成这个?最后结果:

替代文字

php merge overlay resize image

70
推荐指数
4
解决办法
9万
查看次数

如何通过CSS制作不同高度和宽度的所有图像?

我正在尝试创建一个由产品照片组成的图像墙.不幸的是,它们都具有不同的高度和宽度.如何使用css使所有图像看起来大小相同?最好是100 x 100.

我正在考虑做一个高度和宽度为100px的div,然后是一些如何填充它.不知道怎么做.

我怎么能做到这一点?

html css resize image css3

67
推荐指数
4
解决办法
24万
查看次数

输入类型"数字"不会调整大小

当我将类型更改为type="number"但它可以使用时,为什么我的输入不会调整大小type="text"

    Email: <input type="text" name="email" size="10"><br/>
  number: <input type="number" name="email" size="10">
Run Code Online (Sandbox Code Playgroud)

html text resize numbers input

64
推荐指数
4
解决办法
9万
查看次数

Numpy调整大小/重新缩放图像

我想拍摄图像并改变图像的比例,而它是一个numpy数组.

例如,我有一个可口可乐瓶的图像: 瓶-1

这转换为一个numpy形状的形状(528, 203, 3),我想调整大小来说明第二个图像的大小: bottle-2

其中有一个形状(140, 54, 3).

如何在保持原始图像的同时将图像大小更改为特定形状?其他答案建议剥离所有其他或第三行,但我想要做的是基本上缩小图像如何通过图像编辑器,但在python代码.在numpy/SciPy中有没有任何库可以做到这一点?

python resize numpy image scipy

64
推荐指数
6
解决办法
10万
查看次数

Android ImageView调整父级的高度和拟合宽度

更新:我使用本答案中描述的方法解决了这个问题

我对这个问题有点困惑,我认为应该很简单.

所以我的应用程序下载了一个图像,并在ImageView中呈现位图,ImageView是RelativeLayout的子元素.我希望ImageView适合父宽度,并调整它的大小以保持纵横比.

这是我的XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout android:id="@+id/banner" android:layout_width="fill_parent" android:layout_height="wrap_content"></RelativeLayout>
<TextView  
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="@string/hello"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

和代码:

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


    RelativeLayout banner = (RelativeLayout) findViewById(R.id.banner);
    ImageView imgV = new ImageView(this);

    imgV.setScaleType(ImageView.ScaleType.CENTER_CROP);
    // I tried all the scale types : CENTER_INSIDE : same effect, FIT_CENTER : same effect... 

    imgV.setBackgroundColor(0x00FFFF00);

    imgV.setAdjustViewBounds(Color.BLUE);


    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    banner.addView(imgV,params);

    // Some code downloading the image stream

    bitmap = BitmapFactory.decodeStream(stream); …
Run Code Online (Sandbox Code Playgroud)

android resize imageview

62
推荐指数
3
解决办法
9万
查看次数

AngularJS:绑定到指令中的全局事件的最佳方法是什么

想象一下AngularJS中你想要创建一个需要响应全局事件的指令的情况.在这种情况下,假设窗口调整大小事件.

对此最好的方法是什么?我看到它的方式,我们有两个选择:1.让每个指令绑定到事件并在当前元素上做它的魔术2.创建一个全局事件监听器,它执行DOM选择器以获取逻辑应该在其上的每个元素应用.

选项1的优点是您已经可以访问要执行某些操作的元素.但是......选项2的优点是您不必在同一事件上多次绑定(对于每个指令),这可能是性能优势.

我们来说明两个选项:

选项1:

angular.module('app').directive('myDirective', function(){

     function doSomethingFancy(el){
         // In here we have our operations on the element
    }

    return {
        link: function(scope, element){
             // Bind to the window resize event for each directive instance.
             angular.element(window).on('resize', function(){
                  doSomethingFancy(element);
             });
        }
    };
});
Run Code Online (Sandbox Code Playgroud)

选项2:

angular.module('app').directive('myDirective', function(){

    function doSomethingFancy(){
         var elements = document.querySelectorAll('[my-directive]');
         angular.forEach(elements, function(el){
             // In here we have our operations on the element
         });
    }

    return {
        link: function(scope, element){
             // Maybe we have to do something in here, …
Run Code Online (Sandbox Code Playgroud)

javascript events resize directive angularjs

61
推荐指数
2
解决办法
6万
查看次数

使用CSS自动调整浏览器大小的图像

当我调整浏览器窗口大小时,我希望所有(或只是一些)图像自动调整大小.我发现了以下代码 - 但它没有做任何事情.

HTML

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <link rel="stylesheet" href="style.css" type="text/css" media="screen" />
    </head>
    <body>
        <div id="icons">
            <div id="contact">
                <img src="img/icon_contact.png" alt="" />
            </div>
            <img src="img/icon_links.png" alt="" />
        </div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

CSS

body {
    font-family: Arial;
    font-size: 11px;
    color: #ffffff;
    background: #202020 url(../../img/body_back.jpg) no-repeat top center fixed;
    background-size: cover;
}

#icons {
    position: absolute;
    bottom: 22%;
    right: 8%;
    width: 400px;
    height: 80px;
    z-index: 8;
    transform: rotate(-57deg); 
    -ms-transform: rotate(-57deg); 
    -webkit-transform: rotate(-57deg); …
Run Code Online (Sandbox Code Playgroud)

css resize responsive-design

60
推荐指数
2
解决办法
36万
查看次数