我按照本教程创建GridView:
这一行:
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
Run Code Online (Sandbox Code Playgroud)
尺寸85x85非常适合我的Wildfire,但在HTC Desire上看起来很小.如何根据屏幕更改图像大小?
我有2种不同的布局,但GridviewXML文件中没有任何属性来更改图像大小.
这是将图像缩小到指定的较小尺寸的功能代码.但它有几件不好的事情:
我想改进它.有没有办法获得更好的初始估计来排除这么多次迭代?我错了吗?我创建它的原因是接受任何未知大小的图像并将其缩放到一定的大小.这样可以更好地规划存储需求.当您缩放到某个高度/宽度时,图像大小可能会因我们的需要而变化太大.
您将需要一个参考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) 我已经能够获得以下尺寸:
一组六个广义密度:
这些是尺寸:
但是使用诸如XXLarge和XXXlarge屏幕之类的设备的图像和图标大小的理想尺寸应该是什么。
我在调用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) 所以我已经为同一个问题阅读了一堆其他解决方案,但它们似乎都没有用.
我有一堆图像,其中大部分都是在页面加载时隐藏的.只有第一张图像可见.我需要做的是给它们一个负的上边距,使图像垂直居中.唯一的问题是,我现在的代码非常不一致,只是时不时地工作.我实际上不确定这是我的代码还是图像被缓存或其他东西.
这就是我所拥有的:
$('#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) 我已经开始使用 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%"对我也不起作用。
我想对上传的图像大小添加限制(当前图像上传到服务器).
当有人从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) 我为登录屏幕创建了不同大小的背景图像.
我指的是苹果链接https://developer.apple.com/ios/human-interface-guidelines/graphics/launch-screen/
但是我没有使用Launch Screen,我只是想在Login屏幕上添加背景.
我想知道哪个是1x,2x和3x?
另一个问题是当我创建图像集时,应该将图像的大小拖到哪个位置.我不知道那个.或者我们只需要3张图片(通用行)?
那么,景观图像怎么样?我应该把它放在哪里?

无论我在做什么,我都有 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)
网址在这里
如何从@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)
我怎样才能正确地得到这个?我的代码不起作用。
image-size ×10
image ×4
android ×2
c# ×2
css ×2
blackberry ×1
file ×1
gridview ×1
hidden ×1
html ×1
ios ×1
java-me ×1
jpeg ×1
jquery ×1
laravel ×1
launchimage ×1
material-ui ×1
php ×1
reactjs ×1
reduce ×1
screen-size ×1
swift ×1
uiimage ×1
wordpress ×1