Существуют многие, многие, много доступных мер защиты. Ключ:
Ничто не является небьющимся, таким образом, более важно измерить эти вещи, и выбрать хорошую защиту, чем просто хлопнуть на лучшей (худшей) защите Вы в состоянии предоставить.
И изменения вышеупомянутого.
-Adam
The resolution doesn't change the number of pixels, just the display size of a pixel -- increasing resolution makes the display larger, but doesn't make the file larger.
If you make a JPEG that repeats the same information over and over again it will get bigger -- the compression is on a 8x8 cell basis -- if you have more cells, you'll have more data. To make them bigger, encode with quality set to 100. Another thing, JPEG strips out luminance on a cell basis, so variation in hue compresses worse than variation in luminance.
I used my company's product, DotImage, to create a 10mb jpg with this code. You could download an eval and try it out, or do the same with your image SDK.
using System;
using System.Drawing;
using Atalasoft.Imaging;
using Atalasoft.Imaging.Codec;
using Atalasoft.Imaging.Drawing;
namespace MakeLargeImage
{
class Program
{
static void Main(string[] args)
{
AtalaImage img = new AtalaImage(1000, 8000, PixelFormat.Pixel24bppBgr);
Canvas c = new Canvas(img);
for (int block = 0; block < img.Height; block += 1000)
{
for (int line = 0; line < 1000; line += 4)
{
int y = block + line;
c.DrawLine(new Point(0, y), new Point(img.Width, block), new AtalaPen(Color.Yellow));
c.DrawLine(new Point(0, y + 1), new Point(img.Width, y + 1), new AtalaPen(Color.Red));
c.DrawLine(new Point(0, y + 2), new Point(img.Width, y + 2), new AtalaPen(Color.Green));
c.DrawLine(new Point(0, block), new Point(img.Width, y + 3), new AtalaPen(Color.Blue));
}
}
JpegEncoder jpeg = new JpegEncoder(100);
img.Save("10mb.jpg", jpeg, null);
}
}
}
If you make the image pixel size larger, the JPEG file will get larger. You could also add in meta-data, but it's hard to get a big file with just meta-data as there are some size limitations.
PDF is the easiest -- just make a big page with uncompressed image and keep adding pages -- it will get big fast -- there's no compression unless you turn it on. You can do this easily in DotImage with the PdfEncoder
-- just give it a list of jpgs in a FileSystemImageSource
-- code not shown as to not bore everyone, but I'd be happy to provide it to anyone that wants it -- just call Atalasoft and ask for me (or open a support case and reference this question.
Это всего лишь предложение. Не знаю, сработает ли это.
Возможно, вы могли бы сгенерировать растровые изображения правильного размера и преобразовать их?
Если вы сделаете растровые изображения очень сложными для сжатия (1)? После этого вы сможете преобразовать их в jpg и png, очень близкие к целевому размеру.
(1) Я предлагаю, чтобы этого можно было достичь, сделав каждый пиксель в растровом изображении другого цвета (насколько это возможно)
Редактировать:
Это простое решение, вероятно, не работает для jpg, но, по крайней мере, png, похоже, работает.
Я собрал небольшое тестовое приложение на C #, чтобы попробовать его. Вот его суть:
private void make_bitmap(int width, int height)
{
Random random = new Random();
Bitmap B = new Bitmap(width, height);
int redvalue = 0;
int greenvalue = 0;
int bluevalue = 0;
bool pick_random_color = true;
for (int x = 0; x < width; x++)
{
for (int y = 0; y < width; y++)
{
Color col;
if (pick_random_color)
{
col = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));
}
else // iterate over all colours repeatedly
{
if (redvalue == 255) { redvalue = 0; greenvalue++; } else { redvalue++; }
if (greenvalue == 256) { greenvalue = 0; bluevalue++; }
if (bluevalue == 256) { redvalue = 0; greenvalue = 0; bluevalue = 0; }
col = Color.FromArgb(redvalue, greenvalue, bluevalue);
}
B.SetPixel(x, y, col);
}
}
B.Save("image.bmp");
B.Save("image.jpg", ImageFormat.Jpeg);
B.Save("image.png", ImageFormat.Png);
B.Dispose();
}
Должны ли файлы иметь внутренний формат JPEG или просто произвольные двоичные файлы с именем JPEG? В последнем случае см. Ответ на вопрос о переполнении стека:
Создание огромного файла-пустышки за считанные секунды на C #
Я бы начал с «огромного» файла во всех этих форматах (больше максимального размера), а затем итеративно изменял их размер, используя imagemagick convert , пока вы не нашли особенности для требуемый размер файла.
Может потребоваться метод проб и ошибок (хотя может быть легко написан скрипт), но подойдет для одноразового эксперимента.