diff options
| author | Juan Linietsky | 2014-05-24 01:35:47 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2014-05-24 01:35:47 -0300 |
| commit | 1cad087969efefa401a11051343cd0689f660770 (patch) | |
| tree | 1595dd049bdb7289752012dca4398b2251fb08fa /core/image.cpp | |
| parent | f9ff086235cd4ff406b136f62fff77b85c0873f9 (diff) | |
| download | godot-1cad087969efefa401a11051343cd0689f660770.tar.gz godot-1cad087969efefa401a11051343cd0689f660770.tar.zst godot-1cad087969efefa401a11051343cd0689f660770.zip | |
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.
Diffstat (limited to 'core/image.cpp')
| -rw-r--r-- | core/image.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/core/image.cpp b/core/image.cpp index ccabd04d6..db20862af 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -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) |
