gpt4 book ai didi

android - 什么是 Canvas 的 iOS 等价物?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:08:34 25 4
gpt4 key购买 nike

我正在将我的 OGLES 应用程序从 Android 移植到 iOS,并动态制作图像以像这样绑定(bind)为纹理:

        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);

最佳答案

等效于使用 Quartz 2D 和

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

然后您可以将上下文导出为 UIImage。

关于android - 什么是 Canvas 的 iOS 等价物?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8796898/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com