以编程方式创建图像的缩略图 [英] creating thumbnail of an image programmatically

查看:52
本文介绍了以编程方式创建图像的缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我正在从服务器获取图像,并且能够在图像视图中显示图像.... 但是现在我想将从服务器获取的图像存储在表格视图中,并在表格视图单元格中单击时显示它们.我想要的是如何制作图像的缩略图,以便在表格视图单元格中显示它.如果我直接在表格视图单元格中显示图像,则它显得有些笨拙....为此,我要制作缩略图并将其显示在表格视图单元格中...

in my application i am getting images from the server and i am able to display the images in image view.... but now i want to store the images getting from the server in a table view and display them while clicking in the table view cell . what i want is how to make the thumbnail of the image in order to display it in table view cell .if i display the image directly in table view cell it is some what appearing clumsy.... for that i want to make the thumbnail of that image and to display it in table view cell...

任何人都可以帮助我如何以编程方式创建图像的缩略图吗……

can any one please help me how to create thumbnail of a image programatically......

推荐答案

- (void) createThumbView { float y_axis = Set y axis;

int x = 0;

int totalImgs = total images;

int tempCnt = 0;

for (int i = 0; i < totalImgs;)
{
    float x_axis = set x axis;

    int loopCount = 0;

    if (totalImgs - tempCnt >= (no of images in row))
    {
        loopCount = (no of images in row);
    }
    else
    {
        loopCount = totalImgs % (no of images in row);
    }

    for (int j = 0; j < loopCount; j++)
    {
        MasksData *mData = [masksList objectAtIndex:x];

        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame = CGRectMake(x_axis, y_axis, width, height);
        [btn setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@.png",mData.bgImage]] forState:UIControlStateNormal];
        btn.backgroundColor = [UIColor  clearColor];
        btn.tag = x;
        [scroll View addSubview:btn];

        //photoCount++;
        x_axis += width + some space;

        tempCnt++;
        i++;
        x++;
    }

    y_axis += height + some space;

    scroll View.contentSize = CGSizeMake(320.0, y_axis);
}

这篇关于以编程方式创建图像的缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆