- NSBundle* bundle = [ NSBundle bundleForClass : [ class_id class ] ];
- // class_id - self gui
- NSString* fileName = [ bundle pathForResource:@"logo" ofType:@"png" ];
суббота, 20 ноября 2010 г.
Get resource from bundle screensaver
вторник, 7 сентября 2010 г.
NSString to wstring
NSString to std::wstring & std::wstring to NSString
.
- std::wstring NSStringToStringW ( NSString* Str )
- {
- NSStringEncoding pEncode = CFStringConvertEncodingToNSStringEncoding ( kCFStringEncodingUTF32LE );
- NSData* pSData = [ Str dataUsingEncoding : pEncode ];
- return std::wstring ( (wchar_t*) [ pSData bytes ], [ pSData length] / sizeof ( wchar_t ) );
- }
- NSString* StringWToNSString ( const std::wstring& Str )
- {
- NSString* pString = [ [ NSString alloc ]
- initWithBytes : (char*)Str.data()
- length : Str.size() * sizeof(wchar_t)
- encoding : CFStringConvertEncodingToNSStringEncoding ( kCFStringEncodingUTF32LE ) ];
- return pString;
- }
понедельник, 6 сентября 2010 г.
Create a context for the drawing of the buffer.
CGContext Reference
CGColorSpace Reference
.
CGColorSpace Reference
- int ImageWidth = 512;
- int ImageHeight = 512;
- unsigned char* pBuffer = NULL;
- CGContextRef CreateBitmapContext ()
- {
- CGContextRef pContext = NULL;
- CGColorSpaceRef ColorSpace = CGColorSpaceCreateDeviceRGB ();
- int bitmapByteCount = ( ImageWidth * 4 );
- int bitmapBytesPerRow = ( bitmapBytesPerRow * ImageWidth );
- pBuffer = new unsigned char [ bitmapByteCount ];
- if ( NULL == pBuffer )
- {
- delete [] pBuffer;
- CGColorSpaceRelease ( ColorSpace );
- return NULL;
- }
- pContext = CGBitmapContextCreate (
- pBuffer,
- ImageWidth,
- ImageHeight,
- 8,
- bitmapBytesPerRow,
- ColorSpace,
- kCGImageAlphaPremultipliedLast );
- if ( NULL == pContext )
- {
- delete [] m_pBuffer;
- CGColorSpaceRelease( colorSpace );
- return NULL;
- }
- CGColorSpaceRelease ( ColorSpace );
- return pContext;
- }
среда, 1 сентября 2010 г.
Create custom font from bundle.
Use Quartz 2D objects to create custom font.
CGFont Reference
CGDataProviderRef
CGFont Reference
CGDataProviderRef
- CGFontRef FontFromBundle ( NSString* FontName )
- {
- CGFontRef font = NULL;
- NSString* fontPath = [ [ NSBundle mainBundle ] pathForResource : FontName ofType : @"ttf" ];
- CGDataProviderRef fontProvider = CGDataProviderCreateWithFilename([fontPath UTF8String]);
- font = CGFontCreateWithDataProvider ( fontProvider );
- CGDataProviderRelease ( fontProvider );
- return font;
- }
Подписаться на:
Сообщения (Atom)