/* returns: data address and size of the component, if idx is valid 0 in data and len, if idx is out of range  */
void image_multi_getimg(const image_header_t *hdr, ulong idx, ulong *data, ulong *len)
/* returns: data address and size of the component, if idx is valid 0 in data and len, if idx is out of range  */
void image_multi_getimg(const image_header_t *hdr, ulong idx, ulong *data, ulong *len)
{
	int i;
	uint32_t *size;
	ulong offset, count, img_data;
	count = image_multi_count(hdr);
	size = (uint32_t *)image_get_data(hdr);
	img_data = image_get_data(hdr) + (count + 1) * sizeof(uint32_t);
	if (idx < count) {
		*len = uimage_to_cpu(size[idx]);
		offset = 0;
		for (i = 0; i < idx; i++) {
			offset += (uimage_to_cpu(size[i]) + 3) & ~3 ;
		}
		*data = img_data + offset;
	} else {
		*len = 0;
		*data = 0;
	}
}