2012-01-10 5 views
3

им портирование моего приложения OGLES к прошивке от Android, и динамически создать изображение, чтобы связать в качестве текстуры, как так:Что такое iOS-эквивалент холста?

 Bitmap overlayBitmap = Bitmap.createBitmap(512,512, Bitmap.Config.ARGB_4444); 
     // get a canvas to paint over the bitmap 
     Canvas canvas = new Canvas(overlayBitmap); 
     overlayBitmap.eraseColor(0); 
     // Draw the text 
     TextPaint textPaint = new TextPaint(); 
     textPaint.setTextSize(30); 
     textPaint.setAntiAlias(true); 
     textPaint.setARGB(0xff, 0x00, 0x00, 0x00); 
     textPaint.setTypeface(Typeface.DEFAULT_BOLD); 
     textPaint.measureText(stopName); 

     // get a background image from resources 
     // note the image format must match the bitmap format 
     cap.setBounds(0,0,8,49); 
     cap.draw(canvas); 
     overlayBackground.setBounds(8,0, (int) textPaint.measureText(stopName)+8, 49); 
     overlayBackground.draw(canvas); // draw the background to our bitmap 
     Rect overlayBounds=overlayBackground.getBounds(); 
     spike.setBounds((((overlayBounds.right+8)/2)-((21/2))),48,(((overlayBounds.right+8)/2)+((21/2))),69); 
     spike.draw(canvas); 
     capR.setBounds(overlayBounds.right,0,overlayBounds.right+8,49);  
     capR.draw(canvas); 
     // draw the text centered 
     canvas.drawText(stopName,8,33, textPaint); 
+0

Я считаю, что это экземпляр EAGLContext – Daniel

+0

Я думаю, что CoreGraphics Apis iOS эквивалентны для перевода вашего кода, что может помочь создать собственное изображение с графическим рисунком. – Richard

+0

Я пытаюсь выяснить, как сделать обратное. Мой вопрос: откуда взялись «колпак» и «шип»? –

ответ

3

Эквивалента является с помощи Quartz 2D и

UIGraphicsBeginImageContextWithOptions(); 
CGContextRef context = UIGraphicsGetCurrentContext(); //get the context we just made above 

, то вы можете экспортируйте контекст как UIImage.

Смежные вопросы