Comments (4)
Not long ago I added following safety check for DynamicSprite.Create:
if (width <= 0 || height <= 0)
{
debug_script_warn("WARNING: DynamicSprite.Create: invalid size %d x %d, will adjust", width, height);
width = std::max(1, width);
height = std::max(1, height);
}
IIRC this was done for backwards compatibility.
I believe then same should be added to CreateFromDrawingSurface for consistency.
from ags.
Alright, so what happens here actually is that the bitmap is created with correct color depth, but when trying to put it into a SpriteCache, SpriteCache rejects it as being "size = 0", and the slot remains empty. Next time this sprite is requested, SpriteCache returns a placeholder, which is a 1x1 8-bit image. It looks like it's 8-bit by coincidence.
What needs to be done here is to check the result of setting a sprite into a SpriteCache, and also check whether bitmap is valid earlier when adding a dynamic sprite, and make sure that DynamicSprite.Create... functions return null if something like this happens.
There are actually asserts for width or height being zero in allegro code when a bitmap is created but neither of them are triggered when running in debug for me.
Allegro code allows width to be zero, but requires height to be non-zero:
ASSERT(width >= 0);
ASSERT(height > 0);
EDIT: the "background" in a warning should be replaced with "destination" or "surface", as this code runs for any drawing surface, not just room background.
from ags.
Okay, I pushed 3 small commits in regards to this:
9c54262
83e78fb
9d12250
- if dynamic sprite could not be added for any reason, the script functions will return null pointer instead of a invalid DynamicSprite object.
- in DynamicSprite.CreateFrom* functions <= 0 width and height will be automatically fixed to 1, with a warning.
from ags.
Thank you! This fixes. Tried in my actual game and also in my test game. Got the [Game][Warn]: (room:1)[R 14] WARNING: DynamicSprite.CreateFromDrawingSurface: invalid size 0 x 100, will adjust
message in the test game.
from ags.
Related Issues (20)
- Debugger: support step-over and step-out commands HOT 3
- Engine: Rendering graphical glitch HOT 9
- AGS 4: Script API: add "split options" for String.Split method HOT 6
- Deprecate 'function' keyword HOT 4
- Expand on_mouse_click callback parameters with click position
- Editor: having multiple project folders which names are different only in letter case breaks the item drag-n-drop HOT 1
- Editor: an option that disables panel dragging and un-docking
- Editor: restore document panes when resetting a layout
- Preprocessor gets infinite loop meeting a non-latin unicode char in script HOT 3
- Typos in DistanceBetween routine cause wrong calculation HOT 3
- Engine: Windows freezes on Alt+Tab for a specific player HOT 17
- Script API: add "startIndex" parameter to String.IndexOf HOT 26
- Editor: Ctrl+C / Ctrl+V key shortcuts do not work in GUI editor HOT 1
- Editor and Engine: Make it easier to use the project prerequisites (SDL, Ogg, etc) HOT 7
- Feat. req. Pre 2.5 version games support (DOS, 3.11) for Windows runtime engine HOT 1
- AGS 4: remove 16-bit game color depth HOT 2
- Editor: batch-resave all project rooms in the latest format HOT 1
- AGS 4: in Script API change default values of "caseSensitive" parameters to "true"
- [AGS 4.00.00.07] Sierra style template and Tumbleweed template don't work HOT 4
- Support rasterizing the Room viewport to a dynamic sprite HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ags.