Making Godot Easier to Use..
-=-=-=-=-=-=-=-=-=-=-=-=-=-= -Auto indenter in code editor, this makes it much easier to paste external code. -Zoom in 2D viewport now uses the mouse pointer as reference. -Obscure hack to see where code/line of GDScript in C++ backtrace. -Fixed a bug where keys would get stuck on X11 if pressed simultaneously -Added Api on IP singleton to request local IPs. -Premultiplied alpha support when importing texture, editing PNGs and as a blend mode.
This commit is contained in:
@ -1660,6 +1660,31 @@ void Image::set_compress_bc_func(void (*p_compress_func)(Image *)) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Image::premultiply_alpha() {
|
||||
|
||||
if (data.size()==0)
|
||||
return;
|
||||
|
||||
if (format!=FORMAT_RGBA)
|
||||
return; //not needed
|
||||
|
||||
DVector<uint8_t>::Write wp = data.write();
|
||||
unsigned char *data_ptr=wp.ptr();
|
||||
|
||||
|
||||
for(int i=0;i<height;i++) {
|
||||
for(int j=0;j<width;j++) {
|
||||
|
||||
BColor bc = _get_pixel(j,i,data_ptr,0);
|
||||
bc.r=(int(bc.r)*int(bc.a))>>8;
|
||||
bc.g=(int(bc.g)*int(bc.a))>>8;
|
||||
bc.b=(int(bc.b)*int(bc.a))>>8;
|
||||
_put_pixel(j,i,bc,data_ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Image::fix_alpha_edges() {
|
||||
|
||||
if (data.size()==0)
|
||||
|
||||
Reference in New Issue
Block a user