-
-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
// Function to return an array with all points and RGB colors.
EMB_PUBLIC EmbStitchInfo* emb_pattern_getAllStitches(EmbPattern* pattern, int* stitchCount) {
if (!pattern || !pattern->stitch_list || !stitchCount) return NULL;
*stitchCount = pattern->stitch_list->count; // Define o número de pontos
EmbStitchInfo* stitches = (EmbStitchInfo*)malloc(*stitchCount * sizeof(EmbStitchInfo));
if (!stitches) return NULL;
for (int i = 0; i < *stitchCount; i++) {
stitches[i].x = pattern->stitch_list->stitch[i].x;
stitches[i].y = pattern->stitch_list->stitch[i].y;
stitches[i].flags = pattern->stitch_list->stitch[i].flags;
int colorIndex = pattern->stitch_list->stitch[i].color;
if (colorIndex < pattern->thread_list->count) {
EmbColor color = pattern->thread_list->thread[colorIndex].color;
stitches[i].red = color.r;
stitches[i].green = color.g;
stitches[i].blue = color.b;
}
else {
// Cor padrão caso o índice não seja válido
stitches[i].red = 0;
stitches[i].green = 0;
stitches[i].blue = 0;
}
}
return stitches;
}
EMB_PUBLIC void emb_freeStitchInfoList(EmbStitchInfo* stitches) {
free(stitches);
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels