小编Tha*_*des的帖子

直接从C#中的URL获取图像尺寸

我正在尝试使用以下代码直接从网络上获取图片中的尺寸:

string image = @"http://www.hephaestusproject.com/blog/wp-content/uploads/2014/01/csharp3.png";
byte[] imageData = new WebClient().DownloadData(image);
MemoryStream imgStream = new MemoryStream(imageData);
Image img = Image.FromStream(imgStream);

int wSize = img.Width;
int hSize = img.Height;
Run Code Online (Sandbox Code Playgroud)

它工作但性能很糟糕,因为我需要下载许多图像才能获得它们的尺寸.有没有更好的方法来做同样的事情?

c# image download dimensions

10
推荐指数
2
解决办法
6806
查看次数

setInterval不重复

我试图每4秒更改一次背景,但是它会直接跳到第二个条件并且不再改变.为什么会这样?

var time = 1;
var func = function () {
    'use strict';

    if (time === 1) {
        document.getElementById("top-background").style.backgroundColor = "#000";
        time += 1;
    }

    if (time === 2) {
        document.getElementById("top-background").style.backgroundColor = "#aaa";
        time += 1;
    }

    if (time === 3) {
        document.getElementById("top-background").style.backgroundColor = "#d5d5d5";
        time -= 2;
    }

};

setInterval(func, 4000);
Run Code Online (Sandbox Code Playgroud)

javascript intervals web

1
推荐指数
1
解决办法
911
查看次数

标签 统计

c# ×1

dimensions ×1

download ×1

image ×1

intervals ×1

javascript ×1

web ×1