plugin.tx_exampleext_pi1 { templateFile = fileadmin/templates/footemplate.html subPart = ###TEASERSEARCH### } 10 < plugin.tx_exampleext_pi1 oder lib.foo < plugin.tx_exampleext_pi1
PHP TYPO3: configure to output xml
config.xmlprologue = none config.disableAllHeaderCode = 1 page = PAGE page.typeNum = 0 page.10 < plugin.tx_the_ext_that_generates_the_xml_pi1
TypoScript: breadcrumb
lib.breadcrumb = HMENU lib.breadcrumb { special = rootline special.range = 1|-1 1 = TMENU 1 { NO.linkWrap = | > NO.stdWrap2.noTrimWrap = | | | CUR < .NO CUR = 1 CUR { linkWrap = | doNotLinkIt = 1 } } }
PHP Typo3: working with templates in extension
<?php //Templatefile $this->templateCode = $this->cObj->fileResource($tmplfile); $template['content'] = $this->cObj->getSubpart($this->templateCode, '###SUBPART###'); $markerArray['###MARKER1###'] = ''; $markerArray['###MARKER2###'] = ''; $markerArray['###MARKER3###'] = ''; $content = $this->cObj->substituteMarkerArrayCached($template['content'], $markerArray); ?>
Objective-C: convert UIImage to greyscale
- (UIImage *)convertImageToGrayScale:(UIImage *)image { // Create image rectangle with current image width/height CGRect imageRect = CGRectMake(0, 0, image.size.width, image.size.height); // Grayscale color space CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray(); // Create bitmap content with current image size and grayscale colorspace CGContextRef context = CGBitmapContextCreate(nil, image.size.width, image.size.height, 8, 0, colorSpace, kCGImageAlphaNone); // Draw image into current context, with specified rectangle // using previously defined context (with grayscale colorspace) CGContextDrawImage(context, imageRect, [image CGImage]); // Create bitmap image info from pixel data in current context CGImageRef imageRef = CGBitmapContextCreateImage(context); // Create a new UIImage object UIImage *newImage = [UIImage imageWithCGImage:imageRef]; // Release colorspace, context and bitmap information CGColorSpaceRelease(colorSpace); CGContextRelease(context); CFRelease(imageRef); // Return the new grayscale image return newImage; }
Objective-C: resize UIImage proportional
//the following is appropriate call to do this if img is the UIImage instance. //img=[img scaleProportionalToSize:CGSizeMake(320, 480)]; @interface UIImage (UIImageFunctions) - (UIImage *) scaleToSize: (CGSize)size; - (UIImage *) scaleProportionalToSize: (CGSize)size; @end @implementation UIImage (UIImageFunctions) - (UIImage *) scaleToSize: (CGSize)size { // Scalling selected image to targeted size CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(NULL, size.width, size.height, 8, 0, colorSpace, kCGImageAlphaPremultipliedLast); CGContextClearRect(context, CGRectMake(0, 0, size.width, size.height)); if(self.imageOrientation == UIImageOrientationRight) { CGContextRotateCTM(context, -M_PI_2); CGContextTranslateCTM(context, -size.height, 0.0f); CGContextDrawImage(context, CGRectMake(0, 0, size.height, size.width), self.CGImage); } else CGContextDrawImage(context, CGRectMake(0, 0, size.width, size.height), self.CGImage); CGImageRef scaledImage=CGBitmapContextCreateImage(context); CGColorSpaceRelease(colorSpace); CGContextRelease(context); UIImage *image = [UIImage imageWithCGImage: scaledImage]; CGImageRelease(scaledImage); return image; } - (UIImage *) scaleProportionalToSize: (CGSize)size1 { if(self.size.width>self.size.height) { NSLog(@"LandScape"); size1=CGSizeMake((self.size.width/self.size.height)*size1.height,size1.height); } else { NSLog(@"Potrait"); size1=CGSizeMake(size1.width,(self.size.height/self.size.width)*size1.width); } return [self scaleToSize:size1]; } @end
Objective-C: save image in home directory
//save picture NSString *filename = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/pic.png"]; [UIImagePNGRepresentation([info objectForKey:@"UIImagePickerControllerOriginalImage"]) writeToFile:filename atomically:YES];
Objective-C: load/create UIImage from URL and resize
NSString* imageURL = [NSString stringWithFormat: @"http://theimageurl.com/?id=%@", [[resultsEntries objectAtIndex:0] objectForKey: @"image_large"]]; NSData* imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:imageURL]]; UIImage* image = [[UIImage alloc] initWithData:imageData]; // resize image CGSize newSize = CGSizeMake(100, 100); UIGraphicsBeginImageContext( newSize );// a CGSize that has the size you want [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)]; //image is the original UIImage UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); imageHeight = image.size.height; [imageMain setImage:newImage]; [imageData release]; [image release];
Objective-C: create UIImage from URL
NSString* imageURL = @"http://theurl.com/image.gif"; NSData* imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:imageURL]]; UIImage* image = [[UIImage alloc] initWithData:imageData]; [imageView setImage:image]; [imageData release]; [image release]; //or nested version UIImage* myImage = [UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: @"http://www.mydomain.com/image.png"]]]; [myImageView setImage:myImage]; [myImage release];
Objective-C: UIImage rounded corner examples
// UIImage+RoundedCorner.m // Created by Trevor Harmon on 9/20/09. // Free for personal or commercial use, with or without modification. // No warranty is expressed or implied. #import "UIImage+RoundedCorner.h" #import "UIImage+Alpha.h" // Private helper methods @interface UIImage () - (void)addRoundedRectToPath:(CGRect)rect context:(CGContextRef)context ovalWidth:(CGFloat)ovalWidth ovalHeight:(CGFloat)ovalHeight; @end @implementation UIImage (RoundedCorner) // Creates a copy of this image with rounded corners // If borderSize is non-zero, a transparent border of the given size will also be added // Original author: Björn Sållarp. Used with permission. See: http://blog.sallarp.com/iphone-uiimage-round-corners/ - (UIImage *)roundedCornerImage:(NSInteger)cornerSize borderSize:(NSInteger)borderSize { // If the image does not have an alpha layer, add one UIImage *image = [self imageWithAlpha]; // Build a context that's the same dimensions as the new size CGContextRef context = CGBitmapContextCreate(NULL, image.size.width, image.size.height, CGImageGetBitsPerComponent(image.CGImage), 0, CGImageGetColorSpace(image.CGImage), CGImageGetBitmapInfo(image.CGImage)); // Create a clipping path with rounded corners CGContextBeginPath(context); [self addRoundedRectToPath:CGRectMake(borderSize, borderSize, image.size.width - borderSize * 2, image.size.height - borderSize * 2) context:context ovalWidth:cornerSize ovalHeight:cornerSize]; CGContextClosePath(context); CGContextClip(context); // Draw the image to the context; the clipping path will make anything outside the rounded rect transparent CGContextDrawImage(context, CGRectMake(0, 0, image.size.width, image.size.height), image.CGImage); // Create a CGImage from the context CGImageRef clippedImage = CGBitmapContextCreateImage(context); CGContextRelease(context); // Create a UIImage from the CGImage UIImage *roundedImage = [UIImage imageWithCGImage:clippedImage]; CGImageRelease(clippedImage); return roundedImage; } #pragma mark - #pragma mark Private helper methods // Adds a rectangular path to the given context and rounds its corners by the given extents // Original author: Björn Sållarp. Used with permission. See: http://blog.sallarp.com/iphone-uiimage-round-corners/ - (void)addRoundedRectToPath:(CGRect)rect context:(CGContextRef)context ovalWidth:(CGFloat)ovalWidth ovalHeight:(CGFloat)ovalHeight { if (ovalWidth == 0 || ovalHeight == 0) { CGContextAddRect(context, rect); return; } CGContextSaveGState(context); CGContextTranslateCTM(context, CGRectGetMinX(rect), CGRectGetMinY(rect)); CGContextScaleCTM(context, ovalWidth, ovalHeight); CGFloat fw = CGRectGetWidth(rect) / ovalWidth; CGFloat fh = CGRectGetHeight(rect) / ovalHeight; CGContextMoveToPoint(context, fw, fh/2); CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 1); CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 1); CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 1); CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1); CGContextClosePath(context); CGContextRestoreGState(context); } @end
void addRoundedRectToPath(CGContextRef context, CGRect rect, float ovalWidth, float ovalHeight); { float fw, fh; if (ovalWidth == 0 || ovalHeight == 0) { CGContextAddRect(context, rect); return; } CGContextSaveGState(context); CGContextTranslateCTM (context, CGRectGetMinX(rect), CGRectGetMinY(rect)); CGContextScaleCTM (context, ovalWidth, ovalHeight); fw = CGRectGetWidth (rect) / ovalWidth; fh = CGRectGetHeight (rect) / ovalHeight; CGContextMoveToPoint(context, fw, fh/2); CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 1); CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 1); CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 1); CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1); CGContextClosePath(context); CGContextRestoreGState(context); } - (UIImage *)roundCornersOfImage:(UIImage *)source; { int w = source.size.width; int h = source.size.height; CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst); CGContextBeginPath(context); CGRect rect = CGRectMake(0, 0, w, h); addRoundedRectToPath(context, rect, 5, 5); CGContextClosePath(context); CGContextClip(context); CGContextDrawImage(context, CGRectMake(0, 0, w, h), source.CGImage); CGImageRef imageMasked = CGBitmapContextCreateImage(context); CGContextRelease(context); CGColorSpaceRelease(colorSpace); return [UIImage imageWithCGImage:imageMasked]; }