Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2006.04.16;
Скачать: CL | DM;

Вниз

Сохранение bmp файла из image с нужным dpi   Найти похожие ветки 

 
Jimmy   (2005-11-12 18:39) [0]

Подскажите, как сохранить из Image bmp файл с нужным dpi, например равным 300, так как по умолчанию dpi созданной bmp"шки 72 dpi. Заранее спасибо.


 
Gydvin ©   (2005-11-14 06:15) [1]

Вот чуть заколдованный код - BMP, JPG

Высчитываешь размер при нужном тебе  dpi,
сохраняешь в файл, потом этим

procedure tkart.SetResJpg(name: string; dpix, dpiy: Integer);
const
  BufferSize = 50;
  DPI = 1; //inch
 DPC = 2; //cm
var
  Buffer: string;
  index: INTEGER;
  FileStream: TFileStream;
  xResolution: WORD;
  yResolution: WORD;
  _type: Byte;
begin
  FileStream := TFileStream.Create(name,
    fmOpenReadWrite);
  try
    SetLength(Buffer, BufferSize);
    FileStream.Read(buffer[1], BufferSize);
    index := POS("JFIF",buffer);
    if index > 0
      then begin
      FileStream.Seek(index + 6, soFromBeginning);
      _type := DPI;
      FileStream.write(_type, 1);
      xresolution := swap(dpix);
      FileStream.write(xresolution, 2);
      yresolution := swap(dpiy);
      FileStream.write(yresolution, 2);
    end  ;

    index := POS("BM",buffer);
    if index > 0
      then begin
      FileStream.Seek(index + 37, soFromBeginning);
     // FileStream.write(_type, 1);
      xresolution :=  strtoint(floattostr(RoundFloat(strtofloat(inttostr(dpix))*39.4,0)));
      //swap(dpix);
   //   showmessage(floattostr(RoundFloat(strtofloat(inttostr(xresolution))/39.4,0)));
      FileStream.write(xresolution, 2);
       FileStream.Seek(index + 41, soFromBeginning);
      yresolution :=strtoint(floattostr(RoundFloat(strtofloat(inttostr(dpiy))*39.4,0)));

      //swap(dpiy);
      FileStream.write(yresolution, 2);
    end

  finally
    FileStream.Free;
  end;
end;


 
Gydvin ©   (2005-11-14 06:20) [2]

Забыл, тоже надо

function RoundFloat(R: Extended; Decimals: Integer): Extended;
var
Factor: Extended;
begin
Factor := Int(Exp(Decimals * Ln(10)));
Result := Round(Factor * R) / Factor;
end;
function cifrak(s:string):integer;
begin
if s="0" then result:=1 else
if s="1" then result:=1 else
if s="2" then result:=1 else
if s="3" then result:=1 else
if s="4" then result:=1 else
if s="5" then result:=1 else
if s="6" then result:=1 else
if s="7" then result:=1 else
if s="8" then result:=1 else
if s="9" then result:=1 else result:=0;

end;


 
Jimmy   (2005-11-15 19:40) [3]

Спасибо, сейчас попробую разобраться...


 
Jimmy   (2005-11-17 18:53) [4]

Все получилось! Еще раз большое спасибо...



Страницы: 1 вся ветка

Текущий архив: 2006.04.16;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.029 c
2-1143811753
dera
2006-03-31 17:29
2006.04.16
Как выбрать уникальные записи из таблицы?


15-1141663478
Kerk
2006-03-06 19:44
2006.04.16
Конструктор сайтов от Google


8-1132149556
Lazarius
2005-11-16 16:59
2006.04.16
Обработка изображения


15-1143307662
Bogdan1024
2006-03-25 20:27
2006.04.16
скачать книги


2-1143635931
Fl@sh
2006-03-29 16:38
2006.04.16
From TMemoryStream to PByte