#include <stdint.h>
#include <math.h>
void calc_new_sub_area
(
int32_t container_ox, int32_t container_oy, uint32_t container_ow, uint32_t container_oh,
int32_t container_nx, int32_t container_ny, uint32_t container_nw, uint32_t container_nh,
int32_t sub_area_ox, int32_t sub_area_oy, uint32_t sub_area_ow, uint32_t sub_area_oh,
int32_t *sub_area_nx, int32_t *sub_area_ny, uint32_t *sub_area_nw, uint32_t *sub_area_nh
)
{
*sub_area_nx = container_nx + (int32_t)round((float)container_nw * ((float)(sub_area_ox - container_ox) / (float)container_ow));
*sub_area_ny = container_ny + (int32_t)round((float)container_nh * ((float)(sub_area_oy - container_oy) / (float)container_oh));
*sub_area_nw = (uint32_t)round((float)sub_area_ow * ((float)container_nw / (float)container_ow));
*sub_area_nh = (uint32_t)round((float)sub_area_oh * ((float)container_nh / (float)container_oh));
}
Hátha másnak is kell. Köszönet fejesjoco kollégának a hupról. |