Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

Сохранение bmp файла из image с нужным dpi [D5]


Jimmy ©   (2005-11-12 18:39:00) 

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


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

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


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

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


Gydvin   (2005-11-14 06:20:00) [3]

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

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;


Gydvin   (2005-11-14 06:15:00) [4]

Вот чуть заколдованный код - 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;


Наверх

Титульная страница Поиск, карта сайта Написать письмо