public static long ImageDataSize(ImageSize imgsize, string format, float BytesPerPixel) { uint w = imgsize.width; uint h = imgsize.height; if (CprFormat(format)) { if (w < 4) w = 4; if (h < 4) h = 4; } return (long)(w * h * BytesPerPixel); }