How to get scaled the Wimp (system) Sprite? (
Sergey Lentsov (8268) 63 posts |
Hello, I needs to put the small version (2x scaled down) of the Wimp sprite into the treeview control. For example me needs a small version of the “harddisc” sprite. Currently I using another capture operation to my sprite mask and paint the mask using “OS_SpriteOp 50 – Plot Mask Scale” but i get inverted mask. To correct it I must invert every mask pixel. It works but slow as require 2 SWI calls for every pixel. May be another more fast way exists? Here is my C++ code using TBX lib classes to manipulate the sprites. tbx::Size sz, dst_sz; tbx::SpriteArea mask_area; int mode; bool has_mask; wimp_sprite->info(&sz, &mode, &has_mask); dst_sz.height = sz.height / 2; dst_sz.width = sz.width / 2; // 0x301680B5 mode = true color 32bit sprite 90DPI tbx::Sprite user_spr = _treeview_sprite_area.create_sprite_pixels(wimp_sprite->name(), dst_sz.width, dst_sz.height, 0x301680B5, 0, has_mask); tbx::ScaleFactors sf; wimp_sprite->get_wimp_scale(sf); sf.ydiv(sf.ydiv() * 2); sf.xdiv(sf.xdiv() * 2); tbx::SpriteCapture capture_sprite(&user_spr, true, false); wimp_sprite->plot_scaled(0, 0, &sf, 0, tbx::SPA_USE_MASK | (1 << 4)); capture_sprite.release(); if (has_mask) { // capture the mask tbx::SpriteCapture capture_mask(&user_spr, true, true); wimp_sprite->plot_mask_scaled(0, 0, &sf); capture_mask.release(); // invert every mask pixel for(int y = 0; y < dst_sz.height; y++) { for(int x = 0; x < dst_sz.width; x++) { user_spr.mask_pixel(x, y, !user_spr.mask_pixel(x, y)); } } } |
Julie Stamp (8365) 474 posts |
The Filer uses Wimp_PlotIcon. It looks like to call it you just need to fill out a block (wimp_icon in OSLib), there doesn’t need to be an ‘actual’ icon. And then flag wimp_ICON_HALF_SIZE = 0×800 should do the trick. |
Sergey Lentsov (8268) 63 posts |
I can’t use Wimp_PlotIcon because I does not control the Treeview Toolbox control. |
Julie Stamp (8365) 474 posts |
I see. What happens if you use Wimp_PlotIcon after redirecting to your sprite, instead of OS_SpriteOp 52? |
Andrew Conroy (370) 740 posts |
The SH manual says “If used outside the redraw/update loop, the graphic area will be reset to the current screen mode. This is not good if outputing to a sprite.” so I guess this might be a problem. I’m a bit puzzled, does SpriteOp 52 (Put Sprite Scaled) not handle sprites with a mask correctly, if there’s a need to go through and invert the mask again aterwards? |
Sergey Lentsov (8268) 63 posts |
@DavidS Thank you very much. My problem was I tried to plot with R5 bit 3=1 (Use sprite mask/alpha channel).
Thank you! |
Sergey Lentsov (8268) 63 posts |
In addition to previous comment. |