image editoriconfrom image是什么意思思

CLImageEditor
CLImageEditor.bundle
CLAdjustmentTool
brightness.png
brightness@2x.png
contrast.png
contrast@2x.png
saturation.png
saturation@2x.png
CLBlurTool
circle.png
icon_band.png
icon_circle.png
icon_normal.png
CLClippingTool
rotate_btn.png
CLEffectTool
CLBloomEffect.png
CLEffectBase.png
CLGloomEffect.png
CLHighlightShadowEffect.png
CLHueEffect.png
CLPixellateEffect.png
CLPosterizeEffect.png
CLSpotEffect.png
CLFilterTool
CLRotateTool
icon_flip1.png
icon_flip2.png
icon_rotate.png
CLToneCurveTool
ImageTools
CLAdjustmentTool
CLBlurTool
CLClippingTool
CLEffectTool
CLFilterTool
CLRotateTool
CLToneCurveTool
ViewController
_CLImageEditorViewController.xib
CLImageEditorDemo
Base.lproj
Main.storyboard
InfoPlist.strings
Images.xcassets
AppIcon.appiconset
Contents.json
icon29.png
icon29@2x.png
icon40@2x.png
icon57.png
icon57@2x.png
icon60@2x.png
edit.imageset
Contents.json
edit@2x.png
LaunchImage.launchimage
Contents.json
launch1136-1.png
launch1136.png
launch480.png
launch960-1.png
launch960.png
new.imageset
Contents.json
new@2x.png
save.imageset
Contents.json
save@2x.png
CLImageEditorDemo-Info.plist
CLImageEditorDemo-Prefix.pch
default.jpg
sample.jpg
CLImageEditorDemo.xcodeproj
project.xcworkspace
contents.xcworkspacedata
project.pbxproj
.gitignore
CLImageEditor.podspec
UIImage+Utility.m
Created by sho yakushiji on .
Copyright (c) 2013骞?CALACULU. All rights reserved.
#import &UIImage+Utility.h&
#import &Accelerate/Accelerate.h&
@implementation UIImage (Utility)
+ (UIImage*)decode:(UIImage*)image
if(image==nil){ }
UIGraphicsBeginImageContext(image.size);
[image drawAtPoint:CGPointMake(0, 0)];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
+ (UIImage*)fastImageWithData:(NSData *)data
UIImage *image = [UIImage imageWithData:data];
return [self decode:image];
+ (UIImage*)fastImageWithContentsOfFile:(NSString*)path
UIImage *image = [[UIImage alloc] initWithContentsOfFile:path];
return [self decode:image];
#pragma mark- Copy
- (UIImage*)deepCopy
return [UIImage decode:self];
#pragma mark- Resizing
- (UIImage*)resize:(CGSize)size
int W = size.
int H = size.
CGImageRef
= self.CGI
CGColorSpaceRef colorSpaceInfo = CGImageGetColorSpace(imageRef);
CGContextRef bitmap = CGBitmapContextCreate(NULL, W, H, 8, 4*W, colorSpaceInfo, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little);
if(self.imageOrientation == UIImageOrientationLeft || self.imageOrientation == UIImageOrientationRight){
if(self.imageOrientation == UIImageOrientationLeft || self.imageOrientation == UIImageOrientationLeftMirrored){
CGContextRotateCTM (bitmap, M_PI/2);
CGContextTranslateCTM (bitmap, 0, -H);
else if (self.imageOrientation == UIImageOrientationRight || self.imageOrientation == UIImageOrientationRightMirrored){
CGContextRotateCTM (bitmap, -M_PI/2);
CGContextTranslateCTM (bitmap, -W, 0);
else if (self.imageOrientation == UIImageOrientationUp || self.imageOrientation == UIImageOrientationUpMirrored){
// Nothing
else if (self.imageOrientation == UIImageOrientationDown || self.imageOrientation == UIImageOrientationDownMirrored){
CGContextTranslateCTM (bitmap, W, H);
CGContextRotateCTM (bitmap, -M_PI);
CGContextDrawImage(bitmap, CGRectMake(0, 0, W, H), imageRef);
CGImageRef ref = CGBitmapContextCreateImage(bitmap);
UIImage* newImage = [UIImage imageWithCGImage:ref];
CGContextRelease(bitmap);
CGImageRelease(ref);
return newI
- (UIImage*)aspectFit:(CGSize)size
CGFloat ratio = MIN(size.width/self.size.width, size.height/self.size.height);
return [self resize:CGSizeMake(self.size.width*ratio, self.size.height*ratio)];
- (UIImage*)aspectFill:(CGSize)size
return [self aspectFill:size offset:0];
- (UIImage*)aspectFill:(CGSize)size offset:(CGFloat)offset
int W0 = self.size.
int H0 = self.size.
CGImageRef
imageRef = self.CGI
CGColorSpaceRef colorSpaceInfo = CGImageGetColorSpace(imageRef);
CGContextRef bitmap = CGBitmapContextCreate(NULL, W, H, 8, 4*W, colorSpaceInfo, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little);
if(self.imageOrientation == UIImageOrientationLeft || self.imageOrientation == UIImageOrientationRight){
W0 = self.size.
H0 = self.size.
double ratio = MAX(W/(double)W0, H/(double)H0);
W0 = ratio * W0;
H0 = ratio * H0;
int dW = abs((W0-W)/2);
int dH = abs((H0-H)/2);
if(dW==0){ dH += }
if(dH==0){ dW += }
if(self.imageOrientation == UIImageOrientationLeft || self.imageOrientation == UIImageOrientationLeftMirrored){
CGContextRotateCTM (bitmap, M_PI/2);
CGContextTranslateCTM (bitmap, 0, -H);
else if (self.imageOrientation == UIImageOrientationRight || self.imageOrientation == UIImageOrientationRightMirrored){
CGContextRotateCTM (bitmap, -M_PI/2);
CGContextTranslateCTM (bitmap, -W, 0);
else if (self.imageOrientation == UIImageOrientationUp || self.imageOrientation == UIImageOrientationUpMirrored){
// Nothing
else if (self.imageOrientation == UIImageOrientationDown || self.imageOrientation == UIImageOrientationDownMirrored){
CGContextTranslateCTM (bitmap, W, H);
CGContextRotateCTM (bitmap, -M_PI);
CGContextDrawImage(bitmap, CGRectMake(-dW, -dH, W0, H0), imageRef);
CGImageRef ref = CGBitmapContextCreateImage(bitmap);
UIImage* newImage = [UIImage imageWithCGImage:ref];
CGContextRelease(bitmap);
CGImageRelease(ref);
return newI
#pragma mark- Clipping
- (UIImage*)crop:(CGRect)rect
CGPoint origin = CGPointMake(-rect.origin.x, -rect.origin.y);
UIImage *img =
UIGraphicsBeginImageContext(CGSizeMake(rect.size.width, rect.size.height));
[self drawAtPoint:origin];
img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
#pragma mark- Masking
- (UIImage*)maskedImage:(UIImage*)maskImage
CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskImage.CGImage),
CGImageGetHeight(maskImage.CGImage),
CGImageGetBitsPerComponent(maskImage.CGImage),
CGImageGetBitsPerPixel(maskImage.CGImage),
CGImageGetBytesPerRow(maskImage.CGImage),
CGImageGetDataProvider(maskImage.CGImage), NULL, false);
CGImageRef masked = CGImageCreateWithMask(self.CGImage, mask);
UIImage *result = [UIImage imageWithCGImage:masked];
CGImageRelease(mask);
CGImageRelease(masked);
#pragma mark- Blur
- (UIImage*)gaussBlur:(CGFloat)blurLevel
blurLevel = MIN(1.0, MAX(0.0, blurLevel));
int boxSize = (int)(blurLevel * 0.1 * MIN(self.size.width, self.size.height));
boxSize = boxSize - (boxSize % 2) + 1;
NSData *imageData = UIImageJPEGRepresentation(self, 1);
UIImage *tmpImage = [UIImage imageWithData:imageData];
CGImageRef img = tmpImage.CGI
vImage_Buffer inBuffer, outB
void *pixelB
//create vImage_Buffer with data from CGImageRef
CGDataProviderRef inProvider = CGImageGetDataProvider(img);
CFDataRef inBitmapData = CGDataProviderCopyData(inProvider);
inBuffer.width = CGImageGetWidth(img);
inBuffer.height = CGImageGetHeight(img);
inBuffer.rowBytes = CGImageGetBytesPerRow(img);
inBuffer.data = (void*)CFDataGetBytePtr(inBitmapData);
//create vImage_Buffer for output
pixelBuffer = malloc(CGImageGetBytesPerRow(img) * CGImageGetHeight(img));
outBuffer.data = pixelB
outBuffer.width = CGImageGetWidth(img);
outBuffer.height = CGImageGetHeight(img);
outBuffer.rowBytes = CGImageGetBytesPerRow(img);
NSInteger windowR = boxSize/2;
CGFloat sig2 = windowR / 3.0;
if(windowR&0){ sig2 = -1/(2*sig2*sig2); }
int16_t *kernel = (int16_t*)malloc(boxSize*sizeof(int16_t));
for(NSInteger i=0; i&boxS ++i){
kernel[i] = 255*exp(sig2*(i-windowR)*(i-windowR));
sum += kernel[i];
// convolution
error = vImageConvolve_ARGB8888(&inBuffer, &outBuffer, NULL, 0, 0, kernel, boxSize, 1, sum, NULL, kvImageEdgeExtend);
error = vImageConvolve_ARGB8888(&outBuffer, &inBuffer, NULL, 0, 0, kernel, 1, boxSize, sum, NULL, kvImageEdgeExtend);
outBuffer = inB
if (error) {
NSLog(@&error from convolution %ld&, error);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef ctx = CGBitmapContextCreate(outBuffer.data,
outBuffer.width,
outBuffer.height,
outBuffer.rowBytes,
colorSpace,
kCGBitmapAlphaInfoMask & kCGImageAlphaNoneSkipLast);
CGImageRef imageRef = CGBitmapContextCreateImage(ctx);
UIImage *returnImage = [UIImage imageWithCGImage:imageRef];
//clean up
CGContextRelease(ctx);
CGColorSpaceRelease(colorSpace);
free(pixelBuffer);
CFRelease(inBitmapData);
CGImageRelease(imageRef);
return returnI
Copyright(C)
OKBASE.NET All Rights Reserved 好库网 版权所有Current version: 0.9.6.3 RC3
Pixelformer
is a bitmap editor, specifically optimized for creating, modifying, and
converting small and medium-sized images, such as icons, buttons, web
graphics, sprites, etc.
Pixelformer is faster, smaller, easier, more precise, and often more
efficient than large
at the same time it is more
powerful and less limited than classic simple icon editors.
So you need to create, edit, crop, resize, or convert icons or other
small images? Pixelformer can help. Even if you prefer a sophisticated
high-end image editor for creating graphics, Pixelformer would be a useful
tool for doing fast edits, final tweaks, conversions, and optimizations.
click to enlarge...
The main features of Pixelformer are:
No restrictive limits for image dimensions
Pixelformer does not limit you to icon-specific image sizes. Practically,
this means that you generally would not need any additional software while
making, say, an icon from a multi-megapixel photo. Or you can actually
edit large images when a more appropriate tool is not available.
Support for different color depths up to
32-bit RGB with alpha channel
When using Pixelformer, you can always work in the 32-bit RGBA color
space. If you need another format, just specify the output color depth
(from 1 bpp (monochrome) to 32 bpp (RGB with alpha channel)), and Pixelformer
will generate the required bitmap. Even some uncommon formats are supported,
like 16-bit BMP, or 24-bit PNG with transparency, or grayscale PNG with
Semi-transparent colors
In addition to semi-transparent layers and soft-drawing tools, Pixelformer
allows you to use semi-transparent (translucent) colors, offering more
control over transparency effects.
click to enlarge...
Multiple layer support
Any image in a Pixelformer project can be composed of an unlimited number
of layers. The layering greatly simplifies working with complex images.
Free-form masking
Using the selection tools available in Pixelformer, you can create a
region of any arbitrary form and use it for constraining the drawing operations
or for manipulating specific pixels.
In-place supersampling
With Pixelformer, you can draw at a much higher resolution than that
of the output image - the drawing will be instantly resampled and mapped
to the output. This method combines the benefits of raster and vector
graphics and gives you antialiased but still editable image, which can
never be produced by classic 1:1 bitmap editors. Supersampling also helps
to make icons from images by simplifying separation of objects from background
and retaining a possibility to refine the result and align it to pixel
Lossless target color depth switching
Unlike a conventional bitmap editor, Pixelformer virtualizes the image
color space (the working space is always 32-bit RGBA). As a result, changing
the color depth of output bitmaps is very easy and non-destructive.
Independent access to color and
alpha channels
Using Pixelformer, you can independently view and edit color and alpha
cha this feature may be useful for fixing edge artifacts
in imported icons, or for creating unusual blending effects.
Support for multiresolution icons
Ability to handle multiple sizes, resolutions, and color depths of the
same image is essential for a true icon editor or converter. Pixelformer
allows you to work with multiple image formats within a single workspace
and then pack them into a single ICO file.
Dynamic palette generation
Pixelformer frees you from having to worry about color palettes for
non-truecolor images - highly optimized ones can be automatically generated
in real time.
Multiple file format support
At the moment, Pixelformer is able to import BMP, PNG, ICO, CUR, JPEG/JPG,
TGA, and PSD image files, as well as EXE, DLL, or ICL multi
BMP, PNG, ICO, and TGA file formats are available for export. You can
freely convert images between these formats.
Icon extraction capability
Pixelformer can extract icons, cursors, and bitmaps from executable
files and ICL icon libraries.
PNG size optimization
Pixelformer includes a PNG optimizer, which finds optimal PNG compressor
parameters during export, and thus losslessly minimizes size of PNG image
click to enlarge...
Vista icon optimization
Large subimages in Windows 7 and Windows Vista icons can be PNG-
the PNG optimizing engine is able to process them, reducing the corresponding
ICO file sizes.
click to enlarge...
Alpha premultiplication
When necessary, images containing an alpha channel can be exported from
Pixelformer with premultiplied alpha.
click to enlarge...
Deep undo buffer
Pixelformer efficiently compresses undo data, keeping a long history
of operations while maintaining a low memory footprint.#include&&QColor&
#include&&QImage&
#include&&QtGui/QWidget&
class&Widget&:&public&QWidget
&&&&Q_OBJECT
&&&&Q_PROPERTY(QColor&penColor&READ&penColor&WRITE&setPenColor)
&&&&Q_PROPERTY(QImage&iconImage&READ&iconImage&WRITE&setIconImage)
&&&&Q_PROPERTY(int&zoomFactor&READ&zoomFactor&WRITE&setZoomFactor)
&&&&Widget(QWidget&*parent&=&0);
&&&&~Widget();
&&&&void&&&setPenColor(const&QColor&&newColor);
&&&&QColor&penColor()const{return&curC}
&&&&void&&&setZoomFactor(int&newZoom);
&&&&int&&&&zoomFactor()const{return&}
&&&&void&&&setIconImage(const&QImage&&image);
&&&&QImage&iconImage()const{return&}
&&&&QSize&&sizeHint()const;
protected:
&&&&void&&&mousePressEvent(QMouseEvent&*event);
&&&&void&&&mouseMoveEvent(QMouseEvent*&event);
&&&&void&&&paintEvent(QPaintEvent*&event);
&&&&void&&&setImagePixel(const&QPoint&&pos,bool&opaque);
&&&&QRect&&pixelRect(int&i,int&j)const;
&&&&QColor&curC
&&&&QImage&
&&&&int&&&&
#include &QtGui&
#include "widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
this-&setAttribute(Qt::WA_StaticContents);
this-&setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
this-&curColor = Qt::black;
this-&zoom = 8;
image = QImage(16,16,QImage::Format_ARGB32);
image.fill(qRgba(0,0,0,0));
Widget::~Widget()
QSize Widget::sizeHint()const
QSize size = zoom * image.size();
if(zoom &= 3)
size += QSize(1,1);
return size;
void Widget::setPenColor(const QColor& newColor)
curColor = newColor;
void Widget::setIconImage(const QImage& image)
if(this-&image != image)
this-&image = image.convertToFormat(QImage::Format_ARGB32);
this-&updateGeometry();
void Widget::paintEvent(QPaintEvent* event)
QPainter painter(this);
if(zoom &=3)
painter.setPen(this-&palette().foreground().color());
for(int i = 0; i &= image.width();++i)
painter.drawLine(zoom*i,0,zoom*i,zoom*image.height());
for(int j = 0;j &= image.height();j++)
painter.drawLine(0,zoom*j,zoom*image.width(),zoom*j);
for(int i = 0; i & image.width();i++)
for(int j = 0;j & image.height();j++)
QRect rect = this-&pixelRect(i,j);
if(!event-&region().intersect(rect).isEmpty())
QColor color = QColor::fromRgba(image.pixel(i,j));
if(color.alpha() & 255)
painter.fillRect(rect,Qt::white);
painter.fillRect(rect,color);
QRect Widget::pixelRect(int i, int j) const
if(zoom &=3)
return QRect(zoom*i+1,zoom*j+1,zoom-1,zoom-1);
return QRect(zoom*i,zoom*j,zoom,zoom);
void Widget::mousePressEvent(QMouseEvent *event)
if(event-&button() == Qt::LeftButton)
setImagePixel(event-&pos(),true);
else if(event-&button() == Qt::RightButton)
setImagePixel(event-&pos(),false);
void Widget::mouseMoveEvent(QMouseEvent *event)
if(event-&buttons() & Qt::LeftButton)
setImagePixel(event-&pos(),true);
else if(event-&buttons() & Qt::RightButton)
setImagePixel(event-&pos(),false);
void Widget::setImagePixel(const QPoint &pos, bool opaque)
int i = pos.x()/zoom;
int j = pos.y()/zoom;
if(image.rect().contains(i,j))
if(opaque)
image.setPixel(i,j,penColor().rgba());
image.setPixel(i,j,qRgba(0,0,0,0));
this-&update(this-&pixelRect(i,j));
void Widget::setZoomFactor(int newZoom)
if(newZoom & 1)
newZoom = 1;
if(newZoom != zoom)
zoom = newZoom;
updateGeometry();
几点说明:1.宏 Q_PROPERTY 声明属性读写属性2.setSizePolicy(.,.) 说明控件最小尺寸为推荐尺寸3.sizeHint() 获得控件推荐尺寸4.控件 update()/updateGeometry()用于下次重绘和调整控件尺寸5.在函数paintEvent中绘制图元6.一个控件的调色板有3个颜色组 激活,非激活,不可用}

我要回帖

更多关于 imagecache是什么意思 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信