cmkilger / ckimageadditions Goto Github PK
View Code? Open in Web Editor NEWAdditional functions and methods for working with Core Graphics and UIImages on iOS.
Additional functions and methods for working with Core Graphics and UIImages on iOS.
after calling malloc need to set 0 to the buffer in
CoreGraphicsAdditions.c
...
CGContextRef CKBitmapContextAndDataCreate(CGSize size, void ** data) {
...
memset(bitmapData, 0, size.width*size.height*4 );
I am getting this error : library not found for -lImageAdditions
Also : libImageAdditions.a not found
In CKImageCreateByTrimmingTransparency(CGImageRef image, CKImageTrimmingSides sides) a UInt32 array is used instead of an unsigned char array for the bitmap data received from context. It can cause big endian related issues. for example a pixel, when addressed via the UInt32 array will look like this
in the following debug code I have written
(data is defined as unsigned char* data)
int r = data[4*y*width+4*x+0];
int g = data[4*y*width+4*x+1];
int b = data[4*y*width+4*x+2];
int alpha = data[4*y*width+4*x+3];
int xx = ((UInt32*)data)[y*width+x];
in the debugger the values will be as follows
int xx = 0xff01ff00
while the components when addressed via rgba (alpha premultiplied last) are
int r = 0
int g = 0xff
int b = 0x1
int alpha = 0xff
As you can see, in images that have any value of Red the function will be correct, (since most often pixels that have an alpha=0 are also fully zeroed) but in case of almost pure green, (like my test case) it will be incorrect
The Fix is:
redefine
unsigned char * data = bitmapData;
and in the said function use the following code in the scan loops
int alpha = data[4*y*width+4*x+3];
if (alpha != 0)
{
left = x;
goto SCAN_TOP;
}
Thanks for your work on the lib. Hope this helps
I got this error message when use this additions on device 3.0 - 3.2, how to solve this issue?
Program received signal: “EXC_BAD_ACCESS”.
Not safe to look up objc runtime data.
Not safe to look up objc runtime data.
Not safe to look up objc runtime data.
thanks.
You should release the context...
return CGBitmapContextCreateImage(context);
Should be something like ...
CGImageRef image = CGBitmapContextCreateImage(context);
CGContextRelease(context);
return image;
Thanks for this library. However, I seem to have issues using the trimming utility. I assign a UIColor
with RGB colour space, but it doesn't actually trim the image.
Here's an example of an image I am trying to trim:
I'm wanting to trim the black borders on the top and bottom, so I set the UIColor
to [UIColor colorWithRed:0 green:0 blue:0 alpha:1]]
but I am returned the exact same image, nothing is being trimmed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.