How to draw array of pixels?

已查看 71 次
跳至第一个未读帖子

abhishek kumar

未读,
2022年4月7日 11:10:092022/4/7
收件人 skia-discuss
hi 
i want to know how to draw array of pixels.
my program is like

void OnDraw(SkCanvas* canvas)
{

    int *pixels=new int[w*h]; //this array of pixels and i want to draw

    delete[] pixels
}

George Wright

未读,
2022年4月18日 20:08:552022/4/18
收件人 skia-d...@googlegroups.com
You can either wrap that pixel pointer in an SkPixmap object, then you can create an SkImage from the SkPixmap using SkImage::MakeFromRaster(SkPixmap) and use SkCanvas::drawImage() to draw the resulting SkImage to the canvas. This codepath is similar to drawing any other raster image, and will respect clips, transforms, paint attributes etc.

Alternatively, you can call SkCanvas::writePixels() to write the raw pixel data directly into the SkCanvas. This ignores the currently set transform and clip.

Without knowing your usecase it's hard to recommend one or the other.

George

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/7322a497-573a-4e22-b65f-50e227e68a38n%40googlegroups.com.
回复全部
回复作者
转发
0 个新帖子