小编Dav*_*rey的帖子

将透明PNG转换为JPG时覆盖透明度颜色

我正在使用Dragonfly在Rails应用程序中生成缩略图.

我正在以JPG的形式提供所有图片图片.现在客户端正在上传透明的PNG文件,如下所示:

http://www.ibanez.co.jp/products/images/eg2010/ART120_TRF_12_02.png

Dragonfly使用RMagick将这些图像转换为JPG.问题是它将PNG图像转换为具有黑色背景的JPG,而我的网站设计需要白色背景.我试图像这样覆盖它:

encoded_image = Magick::Image.from_blob(image.data).first

if encoded_image.format.downcase == format
  image # do nothing
else
  encoded_image.format = format
  encoded_image.background_color = "white"
  encoded_image.transparent_color = "white"
  encoded_image.to_blob
end
Run Code Online (Sandbox Code Playgroud)

但制作的JPG图像仍然包含黑色背景.在转换透明层时,有谁知道如何击败RMagick使用白色背景?

我知道我可以作为PNG使用,但随后图像的大小是它的10倍,并且该网站的带宽非常大.

ruby rmagick dragonfly-gem

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

无法设置UITableViewCell detailTextLabel.text

如果源存在,则不会显示detailTextLabel.但是相应地显示了textLable.text.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

    }

    // Configure the cell...
    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"favouriteListArray"] != nil) {
        NSArray *listArray = [NSArray arrayWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:@"favouriteListArray"]];
        NSLog(@"listArray:%@", listArray);
        NSDictionary *listDic = [listArray objectAtIndex:indexPath.row];
        NSLog(@"listDic:%@", listDic);
        cell.textLabel.text = [listDic objectForKey:@"Description"];
        cell.detailTextLabel.text = [listDic objectForKey:@"Address"];
    }

    return cell;

}
Run Code Online (Sandbox Code Playgroud)

listDic的NSLog

listDic:{
    Address = myAddress;
    Description = myDescription;
}
Run Code Online (Sandbox Code Playgroud)

iphone uitableview

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

Python文本验证:az和逗号(",")

我需要检查一些文本只包含小写字母az和逗号(",").

在Python中执行此操作的最佳方法是什么?

python regex validation

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

如何在eclipse中提交2个svn存储库

我在SVN存储库中有一个项目.我在Eclipse中有2个项目:一个用于分支,另一个用于trunk.目前我在SVN分公司工作.每当我需要向存储库提交某些内容时,我将其提交到分支,然后复制/粘贴到主干源文件并提交到主干.有什么办法可以在一次操作中提交2个存储库吗?

svn eclipse-plugin commit

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

使用ID和CLASS激活的CSS

我如何使用这个CSS编码,class="active"以便下面显示背景?使用不同的颜色.active,可以这么说(不是:hover).

<a href="[url]" id="curs_section" class="active">kids</a>
Run Code Online (Sandbox Code Playgroud)

我的尝试:

a#curs_section .active  {
    background-color: #66a7eb; 
    color: #333; 
}
Run Code Online (Sandbox Code Playgroud)

css css-selectors

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

如何添加垂直滚动条到道场选择?

我正在动态填充Dojo选择小部件,但列表似乎异常长.如何向其添加垂直滚动条?size属性在这里不起作用.

dojo

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

User Agents如何处理tabindex和z-index的非整数值?

我有一些代码,我支持已tabindex="1.1",tabindex="1.2"等我想改变的值是整数.这会改善浏览器行为吗?

W3C说:

tabindex = 数字 [CN]

此属性指定当前文档的Tab键顺序中当前元素的位置.此值必须是0到32767之间的数字.用户代理应忽略前导零.

它没有说明应该如何处理非整数值.

这篇参考文献说:

数

一个号码.数字必须以连字符或数字开头,并且可以包含小数点.

因此,如果使用小数点,标记是有效的,但它是否有意义?

我的问题是用户代理应该尊重小数点和后面的数字还是只使用整数部分?即,上述两个值应该被视为相同还是不同?为什么你会赞成使用这些值tabindex="11",tabindex="12"等等?z-index也是如此.

html css z-index tabindex

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