标签: image-size

在Android上的GridView中调整图像大小

我按照本教程创建GridView:

这一行:

imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
Run Code Online (Sandbox Code Playgroud)

尺寸85x85非常适合我的Wildfire,但在HTC Desire上看起来很小.如何根据屏幕更改图像大小?

我有2种不同的布局,但GridviewXML文件中没有任何属性来更改图像大小.

android gridview image image-size

5
推荐指数
2
解决办法
8969
查看次数

将jpeg图像的大小调整为指定大小

这是将图像缩小到指定的较小尺寸的功能代码.但它有几件不好的事情:

  • 它很慢
  • 它可以在获得缩放图像之前进行多次迭代
  • 每次必须确定它必须将整个图像加载到memoryStream中的大小

我想改进它.有没有办法获得更好的初始估计来排除这么多次迭代?我错了吗?我创建它的原因是接受任何未知大小的图像并将其缩放到一定的大小.这样可以更好地规划存储需求.当您缩放到某个高度/宽度时,图像大小可能会因我们的需要而变化太大.

您将需要一个参考System.Drawing的参考.

    //Scale down the image till it fits the given file size.
    public static Image ScaleDownToKb(Image img, long targetKilobytes, long quality)
    {
        //DateTime start = DateTime.Now;
        //DateTime end;

        float h, w;
        float halfFactor = 100; // halves itself each iteration
        float testPerc = 100;
        var direction = -1;
        long lastSize = 0;
        var iteration = 0;
        var origH = img.Height;
        var origW = img.Width;

        // if already below target, just return the image
        var size …
Run Code Online (Sandbox Code Playgroud)

c# jpeg image file image-size

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

dp中的XXHDPI和XXXHDPI尺寸,用于Android中的图像和图标

我已经能够获得以下尺寸:

一组六个广义密度:

  • ldpi(低)〜120dpi
  • mdpi(中)〜160dpi
  • hdpi(高)〜240dpi
  • xhdpi(超高)〜320dpi
  • xxhdpi(超高)〜480dpi
  • xxxhdpi(超高)〜640dpi

这些是尺寸:

  • xlarge屏幕至少为960dp x 720dp
  • 大屏幕至少为640dp x 480dp
  • 普通屏幕至少为470dp x 320dp
  • 小萤幕至少为426dp x 320dp

但是使用诸如XXLarge和XXXlarge屏幕之类的设备的图像和图标大小的理想尺寸应该是什么。

android screen-size image-size

5
推荐指数
0
解决办法
35万
查看次数

调用System.Drawing.Image.Save时参数错误无效

我在调用System.Drawing.Image.Save函数时收到无效参数错误.我google并找到了一些建议,但没有任何作用.我想要做的是,当我上传一个图像,如果它比100kb大,我想将图像大小减少一半.请帮忙.

     System.Drawing.Image FullsizeImage = System.Drawing.Image.FromFile(realpath);


                        FullsizeImage = System.Drawing.Image.FromFile(realpath);                    
                        int fileSize = (int)new System.IO.FileInfo(realpath).Length;
                        while (fileSize > 100000) //If Larger than 100KB
                        {
                            SaveJpeg(realpath, FullsizeImage);
                            fileSize = (int)new System.IO.FileInfo(realpath).Length;
                        }



 private static ImageCodecInfo GetEncoderInfo(string mimeType)
    {
        // Get image codecs for all image formats 
        ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();

        // Find the correct image codec 
        for (int i = 0; i < codecs.Length; i++)
            if (codecs[i].MimeType == mimeType)
                return codecs[i];
        return null;
    }

    public static void SaveJpeg(string path, Image img)
        {


            Image …
Run Code Online (Sandbox Code Playgroud)

c# reduce image-size

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

获取隐藏图像的高度?

所以我已经为同一个问题阅读了一堆其他解决方案,但它们似乎都没有用.

我有一堆图像,其中大部分都是在页面加载时隐藏的.只有第一张图像可见.我需要做的是给它们一个负的上边距,使图像垂直居中.唯一的问题是,我现在的代码非常不一致,只是时不时地工作.我实际上不确定这是我的代码还是图像被缓存或其他东西.

这就是我所拥有的:

$('#frontpage-sidebar-slideshow img').each(function(i, v) {

    // I read that preloading the images would solve the problem, but this doesn't do anything
    //var src = $(this).attr('src');
    //$('<img/>')[0].src = src;

    // First make parent .slide visible to be able to get the image dimentions (not possible if image is invisible)
    var showAfter = false;
    if(!$(this).parent('.slide').is(':visible')) {
        showAfter = true;
        $(this).parent('.slide').css({ // .show() might also work
            display: 'block',
            visibility: 'visible',
            opacity: 1
        });
    }

    // Get dimentions
    var wrapHeight …
Run Code Online (Sandbox Code Playgroud)

jquery hidden image image-size

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

material-ui-next:设置图像大小以适合容器

我已经开始使用 Material-ui-next 并且在显示他们使用整个容器大小的图像时遇到了一些问题。例如我使用:

const styles = theme => ({
  Card: {
    width: 300,
    margin: 'auto'
  },
  Media: {
    height: 550
  }
});
Run Code Online (Sandbox Code Playgroud)

在渲染中:

<Card className={classes.Card}>
   <CardMedia
        className={classes.Media}
        image={ImgPomodoR}
        title="a pomodoro tomatoe timer in material design"
   />
   <CardContent>
      <Typography gutterBottom variant="headline" component="h2">
        ...
Run Code Online (Sandbox Code Playgroud)

文档说我必须指定图像的高度才能显示。“媒体”示例使图像的高度为 0,但是,如果我应用我的图像未显示 -提到的示例

现在,对我来说,这是媒体高度的反复试验,它适合 Card 容器而不会被裁剪。有没有“自动”的方式来做到这一点?

任何帮助都受到高度赞赏,欢呼伙伴们,

托比亚斯

编辑:我应该提到height: "100%"//maxHeight: "100%"对我也不起作用。

css image-size reactjs material-ui

4
推荐指数
1
解决办法
2万
查看次数

如何在上传到服务器之前限制BlackBerry上的图像大小

我想对上传的图像大小添加限制(当前图像上传到服务器).

当有人从SD卡获取的图像或从相机捕获的图像,我想显示消息的用户,它最大上传文件大小 - 即500KB或我可以将图像尺寸调整到更小的尺寸.例如,1mb图像大小调整为400-500kb(如Facebook).

以下是从SDcard获取图像或从Camera获取图像后实现的示例代码.

 FileConnection file = (FileConnection)Connector.open(url);
 if(file.exists())
 {
     try{
         String fileName = url .substring(url.lastIndexOf('/') + 1);
         //String fileName = url ;
         Dialog.alert("fileName  " + fileName);
         InputStream inputStream = file.openInputStream();

         ByteArrayOutputStream bos=new ByteArrayOutputStream();
         int buffersize=1024;
         byte[] buffer=new byte[buffersize];
         int length=0;
         while((length=inputStream.read(buffer))!=-1)
         {
             bos.write(buffer,0,length);
         }
         byte[] imagedata=bos.toByteArray();
         Dialog.alert("Url  " + Url  + " Image Data Byte " + imagedata);
         HttpConnection conn = (HttpConnection) Connector.open(Url, Connector.READ_WRITE);
         conn.setRequestMethod(HttpConnection.POST);
         String boundary = "Some_Unique_Text_Also_Alphanumeric";
         conn.setRequestProperty(HttpProtocolConstants.HEADER_CONTENT_TYPE,                    
             HttpProtocolConstants.CONTENT_TYPE_MULTIPART_FORM_DATA
                                 + ";boundary=" + boundary);

             conn.setRequestProperty(HttpProtocolConstants.HEADER_CONTENT_LENGTH, …
Run Code Online (Sandbox Code Playgroud)

blackberry java-me image-size

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

如何从Xcode 8中的Assets.xcassets添加不同屏幕尺寸的图像?

我为登录屏幕创建了不同大小的背景图像.
我指的是苹果链接https://developer.apple.com/ios/human-interface-guidelines/graphics/launch-screen/
但是我没有使用Launch Screen,我只是想在Login屏幕上添加背景.

我想知道哪个是1x,2x和3x?

在此输入图像描述


另一个问题是当我创建图像集时,应该将图像的大小拖到哪个位置.我不知道那个.或者我们只需要3张图片(通用行)?
那么,景观图像怎么样?我应该把它放在哪里? 在此输入图像描述

uiimage ios image-size launchimage swift

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

css 图像被拉伸到 100% 高度

无论我在做什么,我都有 css 拉伸图像,但我看不到图像有多小,但它使它成为我正在使用的巨大高度

<?PHP the_post_thumbnail( 'full' );  ?>
Run Code Online (Sandbox Code Playgroud)

使用的 css 如下但你会看到它的原因在此处输入图片说明 我的图像拉伸并且尺寸不正确。

.services-icon img {
    max-width: 100%;
    display: block;
    width: 200px;
    margin-top: 0;
    margin-right: auto;
    margin-bottom: 0;
    margin-left: auto;
Run Code Online (Sandbox Code Playgroud)

网址在这里

http://www.lockmsiths.solitudesoftware.co.uk/#site

html css wordpress image image-size

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

Laravel @yield 在 php 代码中

如何从@yieldPHP 中获取内容?

我在 app.blade.php 中的示例:

@yield('image-url', asset('/img/metaog.png?2'))
Run Code Online (Sandbox Code Playgroud)

我想从 image-url 获取图像大小:

<?php 
    $image = getimagesize(yield('image-url', asset('/img/metaog.png?2')));
    $width = $image[0];
    $height = $image[1];
?>
Run Code Online (Sandbox Code Playgroud)

我怎样才能正确地得到这个?我的代码不起作用。

php image-size laravel

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