Procházet zdrojové kódy

REDESIGNED: ImageFromImage(), optimized #1218

pull/1280/head
raysan5 před 5 roky
rodič
revize
691c1f9391
1 změnil soubory, kde provedl 15 přidání a 2 odebrání
  1. +15
    -2
      src/textures.c

+ 15
- 2
src/textures.c Zobrazit soubor

@ -776,9 +776,22 @@ Image ImageCopy(Image image)
// Create an image from another image piece
Image ImageFromImage(Image image, Rectangle rec)
{
Image result = ImageCopy(image);
Image result = { 0 };
int bytesPerPixel = GetPixelDataSize(1, 1, image.format);
// TODO: Check rec is valid?
ImageCrop(&result, rec);
result.width = rec.width;
result.height = rec.height;
result.data = RL_CALLOC(rec.width*rec.height*bytesPerPixel, 1);
result.format = image.format;
result.mipmaps = 1;
for (int y = 0; y < rec.height; y++)
{
memcpy(((unsigned char *)result.data) + y*(int)rec.width*bytesPerPixel, ((unsigned char *)image.data) + ((y + (int)rec.y)*image.width + (int)rec.x)*bytesPerPixel, (int)rec.width*bytesPerPixel);
}
return result;
}

Načítá se…
Zrušit
Uložit