The readPixels got black background color,How retain it's transparent settings?

29 views
Skip to first unread message

格尔依

unread,
Jan 14, 2023, 8:01:17 AM1/14/23
to skia-discuss
sk_sp<SkSurface> surface_base = SkSurface::MakeRasterN32Premul(3000, 3000);
sk_sp<SkSurface> surface_front = SkSurface::MakeRasterN32Premul(3000, 3000);

SkCanvas *canvas0 = surface_base->getCanvas();
SkCanvas *canvas1 = surface_front->getCanvas();

//set front transparent color
canvas1->clear(SK_ColorTRANSPARENT);

//draw some to canvas0 and canvas1
...

//merge front to base
SkImageInfo info2 = SkImageInfo::MakeN32Premul(500, 500);
SkPixmap skPixmap;
surface_base->peekPixels(&skPixmap);
surface_front->readPixels(info2, skPixmap.addr(), skPixmap.rowBytes(), 100, 100);   //got black background color.

格尔依

unread,
Jan 15, 2023, 7:42:00 AM1/15/23
to skia-discuss
snapshot.png
Reply all
Reply to author
Forward
0 new messages