{"id":18271310,"url":"https://github.com/sonsongithub/Quartz-Help-Library","last_synced_at":"2025-04-05T01:31:20.183Z","repository":{"id":66551750,"uuid":"1587003","full_name":"sonsongithub/Quartz-Help-Library","owner":"sonsongithub","description":"Quartz Help Library for iOS, for image processing on iOS.","archived":false,"fork":false,"pushed_at":"2012-05-07T08:18:58.000Z","size":2654,"stargazers_count":50,"open_issues_count":0,"forks_count":9,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-30T04:31:34.379Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://sonson.jp","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sonsongithub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-04-08T11:38:52.000Z","updated_at":"2023-08-23T06:29:46.000Z","dependencies_parsed_at":"2023-02-20T06:31:16.322Z","dependency_job_id":null,"html_url":"https://github.com/sonsongithub/Quartz-Help-Library","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonsongithub%2FQuartz-Help-Library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonsongithub%2FQuartz-Help-Library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonsongithub%2FQuartz-Help-Library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonsongithub%2FQuartz-Help-Library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sonsongithub","download_url":"https://codeload.github.com/sonsongithub/Quartz-Help-Library/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276043,"owners_count":20912286,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T11:39:12.857Z","updated_at":"2025-04-05T01:31:15.171Z","avatar_url":"https://github.com/sonsongithub.png","language":"Objective-C","readme":"Quartz Help Library\r=======\r![sample image](http://sonson.jp/wp/wp-content/uploads/2011/04/qhl.png)\r\rThis library helps image processing  programming on iOS. Currently, it includes a mutual converter CGImage \u003c-\u003e pixel array..\rYou can convert them mutually without complicated codes.\r\r\t// original pixel data\r\tint originalWidth = 32;\r\tint originalHeight = 32;\r\tunsigned char* original = (unsigned char*)malloc(sizeof(unsigned char) * originalWidth * originalHeight);\r\t\r\t// make test pattern\r\tfor (int y = 0; y \u003c originalHeight; y++) {\r\t\tfor (int x = 0; x \u003c originalWidth; x++) {\r\t\t\tif (y \u003c= originalHeight / 2 \u0026\u0026 x \u003c= originalWidth / 2) {\r\t\t\t\toriginal[y * originalWidth + x] = 0;\r\t\t\t}\r\t\t\tif (y \u003c= originalHeight / 2 \u0026\u0026 x \u003e originalWidth / 2) {\r\t\t\t\toriginal[y * originalWidth + x] = 85;\r\t\t\t}\r\t\t\tif (y \u003e originalHeight / 2 \u0026\u0026 x \u003c= originalWidth / 2) {\r\t\t\t\toriginal[y * originalWidth + x] = 170;\r\t\t\t}\r\t\t\tif (y \u003e originalHeight / 2 \u0026\u0026 x \u003e originalWidth / 2) {\r\t\t\t\toriginal[y * originalWidth + x] = 255;\r\t\t\t}\r\t\t}\r\t}\r\t\r\tCGImageRef image = CGImageGrayColorCreateWithGrayPixelBuffer(original, originalWidth, originalHeight);\r\t\r\tUIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageWithCGImage:image]];\r\t[self addSubview:imageView];\r\t[imageView release];\r        \rHow to use\r=======\r * Import QuartzCVHelpLibrary.h/m into your project.\r \rLicense\r=======\rBSD License.\r\rUIImage Quartz Help Library Additions Reference\r=======\r\t- (NSData*)PNGRepresentaion;\r###Return value\rAn autoreleased NSData object containing the PNG data, or nil if there was a problem generating the data.\r###Discussion\rYou can obtain PNG data as NSData from UIImage directly.\r\r\t- (NSData*)JPEGRepresentaion;\r###Return value\rAn autoreleased NSData object containing the JPEG data, or nil if there was a problem generating the data. This method uses default JPG compression quiality.\r###Discussion\rYou can obtain JPEG data as NSData from UIImage directly.\r\r\t- (NSData*)JPEGRepresentaionWithCompressionQuality:(float)compressionQuality;\r###Parameters\r###compressionQuality\rThe quality of the resulting JPEG image, expressed as a value from 0.0 to 1.0. The value 0.0 represents the maximum compression (or lowest quality) while the value 1.0 represents the least compression (or best quality).\r###Return value\rAn autoreleased NSData object containing the JPEG data, or nil if there was a problem generating the data. This method uses default JPG compression quiality.\r###Discussion\rYou can obtain JPEG data as NSData from UIImage directly.\r\r\t- (UIImage*)getRotatedImage;\r###Return value\rAn autoreleased bitmap image as UIImage.\r###Discussion\rBitmap image is copied from UIImage which is rotated according to \"imageOrienation\" attribute. Therefore, the size of the image you obtain is not as same as the original UIImage's.\r\r\t- (UIImage*)getRotatedImageWithResizing:(float)scale;\r###Parameters\r###scale\rThe scale factor to used when \"imageRef\" is resized.\r###Return value\rAn autoreleased bitmap image as UIImage.\r###Discussion\rResized bitmap image is copied from UIImage which is rotated according to \"imageOrienation\" attribute. Therefore, the size of the image you obtain is not as same as the original UIImage's.\r\r\t- (CGImageRef)createCGImageRotated;\r###Return value\rA new Quartz bitmap image. You are responsible for releasing this object by calling CGImageRelease.\r###Discussion\rBitmap image is copied from UIImage which is rotated according to \"imageOrienation\" attribute. Therefore, the size of the image you obtain is not as same as the original UIImage's.\r\r\t- (CGImageRef)createCGImageRotatedWithResizing:(float)scale;\r###Parameters\r###scale\rThe scale factor to used when \"imageRef\" is resized.\r###Return value\rA new Quartz bitmap image. You are responsible for releasing this object by calling CGImageRelease.\r###Discussion\rResized bitmap image is copied from UIImage which is rotated according to \"imageOrienation\" attribute. Because createCGImageRotatedWithResizing simultaneously resizes image and adjusts rotation of UIImage with low memory usage, this method has to be used in - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info.\r\rQuartz Help Library Reference\r=======\r\tCGImageRef CGImageCreateWithPNGorJPEGFilePath(\r\t\tCFStringRef filePath\r\t);\r###Parameters\r###filePath\rThe full or relative pathname of your image file, as CFStringRef(NSString).\r###Return value\rA new Quartz bitmap image. You are responsible for releasing this object by calling CGImageRelease.\r###Discussion\rYou can obtain the Quartz bitmap image from the filepath of PNG or JPG file directly.\r\r\tvoid CGImageDumpImageInformation(\r\t\tCGImageRef imageRef\r\t);\r###Parameters\r###imageRef\rThe image to print its information.\r###Discussion\rPrint information of the image to standard output (stdout).\rThe information incudes width, height, bytes per pixel, alpha, byte order, and so on.\r\r\tvoid CGCreatePixelBufferWithImage(\r\t\tCGImageRef imageRef,\r\t\tunsigned char **pixel,\r\t\tint *width,\r\t\tint *height,\r\t\tint *bytesPerPixel,\r\t\tQH_PIXEL_TYPE pType\r\t);\r\t\t\r###Parameters\r###imageRef\rThe image to be copied.\r###pixel\rReturn contains pixel buffer of the image. You are responsible for free this data.\r###width\rReturn contains width of the image.\r###height\rReturn contains pixel of the image.\r###bytesPerPixel\rReturn contains bytes per pixel of returned the pixel buffer.\r###pType\rYour favourite pixel type as specified QH\\_PIXEL\\_TYPE when copying pixel buffer.\r###Discussion\rpType is very important. Specifying QH\\_PIXEL\\_GRAYSCALE, pixel contains gray scale pixel buffer of the image. And then if the image is RGB or RGBA color scale, it is converted to gray scale automatically. The converting algorithm is based on YUV-RGB(Alpha components are filled with default value as 255). On the contrary, specifying QH\\_PIXEL\\_COLOR or QH\\_PIXEL\\_ANYCOLOR when the image is gray scale, automatically pixels' each components are filled with each gray scale value except alpha.\r\r\tCGImageRef CGImageCreateWithPixelBuffer(\r\t\tunsigned char *pixel,\r\t\tint width,\r\t\tint height,\r\t\tint bytesPerPixel,\r\t\tQH_PIXEL_TYPE target_pType\r\t);\r###Parameters\r###pixel\rThe pointer of the pixel buffer to be used to make a new CGImage.\r###width\rWidth of the pixel buffer.\r###height\rHeight of the pixel buffer.\r###bytesPerPixel\rBytes per pixel of the pixel buffer.\r###target_pType\rPixel type of the image to be created with above parameters. Specified QH\\_PIXEL\\_TYPE.\r###Return value\rA new Quartz bitmap image. You are responsible for releasing this object by calling CGImageRelease.\r###Discussion\rUpconverting or downconverting is to be done according to your spceifying `bytesPerPixel` and `target_pType`, like `CGCreatePixelBufferWithImage`.  I doubt that CGImage supports the image whose format is 24 bit per pixel. So, CGImage this method returns is 8bit or 32bit bitmap.\r\r\tNSData* CGImageGetPNGPresentation(\r\t\tCGImageRef imageRef\r\t);\r###Parameters\r###imageRef\rThe image to be converted to PNG data.\r###Return value\rAn autoreleased NSData object containing the PNG data, or nil if there was a problem generating the data.\r###Discussion\rTo be written.\r\r\tNSData* CGImageGetJPEGPresentation(\r\t\tCGImageRef imageRef\r\t);\r###Parameters\r###imageRef\rThe image to be converted to JPG data.\r###Return value\rAn autoreleased NSData object containing the JPG data, or nil if there was a problem generating the data.\r###Discussion\rTo be written.\r\r\tCGImageRef CGImageCreateWithResizing(\r\t\tCGImageRef imageRef,\r\t\tfloat scale\r\t);\r###Parameters\r###imageRef\rThe image to be resized.\r###scale\rThe scale factor to used when \"imageRef\" is resized.\r###Return value\rA new and rotated Quartz bitmap image. You are responsible for releasing this object by calling CGImageRelease.\r###Discussion\rThis function has not been tested yet. Be careful of using this function :-)\r \rConstants\r=======\r\r###In/Out pixel type\r\r\ttypedef enum {\r\t\tQH_PIXEL_GRAYSCALE =\t\t\t0,\r\t\tQH_PIXEL_COLOR =\t\t\t\t1 \u003c\u003c 0,\r\t\tQH_PIXEL_ANYCOLOR =\t\t\t\t1 \u003c\u003c 1,\r\t}QH_PIXEL_TYPE;\r\t\r###QH\\_PIXEL\\_GRAYSCALE\rGray scale pixel for the output/input image. Typically, bits per pixel is 8bits.\r\r###QH\\_PIXEL\\_COLOR\rRGB color scale pixel for the output/input image. Typically, bits per pixel is 24bits.\r\r###QH\\_PIXEL\\_ANYCOLOR\rThe appropriate color scale pixel for the output/input image. I believe that it does suit to output/input image format....\r\r###Bytes per pixel type\r\r\ttypedef enum {\r\t\tQH_BYTES_PER_PIXEL_UNKNOWN =\t0,\r\t\tQH_BYTES_PER_PIXEL_8BIT =\t\t1,\r\t\tQH_BYTES_PER_PIXEL_16BIT =\t\t2,\r\t\tQH_BYTES_PER_PIXEL_24BIT =\t\t3,\r\t\tQH_BYTES_PER_PIXEL_32BIT =\t\t4,\r\t}QH_BYTES_PER_PIXEL;\r\t\r###QH\\_BYTES\\_PER_PIXEL\\_UNKNOWN\rTypically, error.\r\r###QH\\_BYTES\\_PER_PIXEL\\_8BIT\rBytes per pixel is 1. In short, bits per pixel is 8 bit. Typically, index color or gray color image.\r\r###QH\\_BYTES\\_PER_PIXEL\\_16BIT\rBytes per pixel is 2. In short, bits per pixel is 16 bit. Typically, index color or gray color image with alpha component.\r\r###QH\\_BYTES\\_PER_PIXEL\\_24BIT\rBytes per pixel is 3. In short, bits per pixel is 24 bit. Typically, RGB color image.\r\r###QH\\_BYTES\\_PER_PIXEL\\_32BIT\rBytes per pixel is 4. In short, bits per pixel is 32 bit. Typically, RGB color image with alpha component.\r \rBlog\r=======\r * [sonson.jp][]\rSorry, Japanese only....\r\rDependency\r=======\r * none\r \r[Quartz Help Library]: https://github.com/sonsongithub/Quartz-Help-Library\r[sonson.jp]: http://sonson.jp\r","funding_links":[],"categories":["etc"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonsongithub%2FQuartz-Help-Library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsonsongithub%2FQuartz-Help-Library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonsongithub%2FQuartz-Help-Library/lists"}