| 143 | } |
| 144 | |
| 145 | JSValue JSGetImageInfo(JSContext* ctx, ImageIndex id) |
| 146 | { |
| 147 | auto* g1 = GfxGetG1Element(id); |
| 148 | if (g1 == nullptr) |
| 149 | { |
| 150 | return JS_UNDEFINED; |
| 151 | } |
| 152 | |
| 153 | JSValue obj = JS_NewObject(ctx); |
| 154 | JS_SetPropertyStr(ctx, obj, "id", JS_NewInt32(ctx, id)); |
| 155 | JS_SetPropertyStr(ctx, obj, "offset", ToJSValue(ctx, ScreenCoordsXY{ g1->xOffset, g1->yOffset })); |
| 156 | JS_SetPropertyStr(ctx, obj, "width", JS_NewInt32(ctx, g1->width)); |
| 157 | JS_SetPropertyStr(ctx, obj, "height", JS_NewInt32(ctx, g1->height)); |
| 158 | |
| 159 | JS_SetPropertyStr(ctx, obj, "hasTransparent", JS_NewBool(ctx, g1->flags.has(G1Flag::hasTransparency))); |
| 160 | JS_SetPropertyStr(ctx, obj, "isRLE", JS_NewBool(ctx, g1->flags.has(G1Flag::hasRLECompression))); |
| 161 | JS_SetPropertyStr(ctx, obj, "isPalette", JS_NewBool(ctx, g1->flags.has(G1Flag::isPalette))); |
| 162 | JS_SetPropertyStr(ctx, obj, "noZoom", JS_NewBool(ctx, g1->flags.has(G1Flag::noZoomDraw))); |
| 163 | |
| 164 | if (g1->flags.has(G1Flag::hasZoomSprite)) |
| 165 | { |
| 166 | JS_SetPropertyStr(ctx, obj, "nextZoomId", JS_NewInt32(ctx, id - g1->zoomedOffset)); |
| 167 | } |
| 168 | else |
| 169 | { |
| 170 | JS_SetPropertyStr(ctx, obj, "nextZoomId", JS_UNDEFINED); |
| 171 | } |
| 172 | return obj; |
| 173 | } |
| 174 | |
| 175 | static std::string_view GetPixelDataTypeForG1(const G1Element& g1) |
| 176 | { |
no test coverage detected