Saya ingin tanya nich, gimana caranya melakukan konversi dari bmp dari segala ukuran ( misalnya : 100 x 50 pixel atau 600 x 300 pixel ) ke bentuk mini (spt thumbnail) ?
Jawaban
Caranya kelihatannya bisa bermacam-macam. Ini saya coba berikan salah
satu cara yang sederhana.
procedure CreateThumbnail(SrcBmp, DestBmp: TBitmap;
ProportionalResize: Boolean);
var
PropWidth, PropHeight: Integer;
begin
if ProportionalResize then
begin
// mencari ukuran TxL yang proporsional
if SrcBmp.Width/DestBmp.Width < SrcBmp.Height/DestBmp.Height
then
begin
PropWidth := SrcBmp.Width;
PropHeight := PropWidth * DestBmp.Height div DestBmp.Width;
end else
begin
PropHeight := SrcBmp.Height;
PropWidth := PropHeight * DestBmp.Width div DestBmp.Height;
end;
end else
begin
PropWidth := SrcBmp.Width;
PropHeight := SrcBmp.Height;
end;
// dibawah ini kalau nggak mau ber-WinAPI, bisa pakai
// method TCanvas.StretchDraw(), tentunya dengan parameter
// yang berbeda
if not StretchBlt(DestBmp.Canvas.Handle, 0, 0,
DestBmp.Width, DestBmp.Height,
SrcBmp.Canvas.Handle, 0, 0, PropWidth, PropHeight,
SRCCOPY)
then
RaiseLastWin32Error;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
SrcBmp, DestBmp: TBitmap;
begin
SrcBmp := TBitmap.Create;
try
SrcBmp.LoadFromFile('C:\BigSizeBitmap.bmp');
DestBmp := TBitmap.Create;
try
// dimensi thumbnail
DestBmp.Width := 16;
DestBmp.Height := 16;
CreateThumbnail(SrcBmp, DestBmp, True);
// misalnya thumbnail dipakai sebagai glyph
// pada TSpeedButton...
SpeedButton1.Glyph.Assign(DestBmp);
finally
DestBmp.Free;
end;
finally
SrcBmp.Free;
end;
end;
Ads
Translate
Thursday, 1 November 2012
Membuat tumbnail pada Delphi
By Fajar |  November 01, 2012
No comments
Author: Fajar
Hello, I am Author, decode to know more: In commodo magna nisl, ac porta turpis blandit quis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In commodo magna nisl, ac porta turpis blandit quis. Lorem ipsum dolor sit amet.
Best Post This Year
Install Fortesreport community Delphi 7 dan RX Berlin
Download Pertama2 kita harus punya file installernya terlebih dahulu, download https://github.com/fortesinformatica/fortesrepo...
About Me
Total Pageviews
Subscribe Channel TUTORIAL PEMROGRAMAN , Update Guys !
Blog Archive
-
►
2016
(3)
- ► 09/11 - 09/18 (1)
- ► 09/04 - 09/11 (2)
-
►
2015
(19)
- ► 12/27 - 01/03 (3)
- ► 11/08 - 11/15 (1)
- ► 09/13 - 09/20 (1)
- ► 08/23 - 08/30 (1)
- ► 08/09 - 08/16 (1)
- ► 06/28 - 07/05 (1)
- ► 05/24 - 05/31 (1)
- ► 05/17 - 05/24 (2)
- ► 05/10 - 05/17 (1)
- ► 04/26 - 05/03 (1)
- ► 04/05 - 04/12 (2)
- ► 03/29 - 04/05 (2)
- ► 03/08 - 03/15 (1)
- ► 01/25 - 02/01 (1)
-
►
2014
(15)
- ► 11/02 - 11/09 (1)
- ► 10/19 - 10/26 (1)
- ► 09/21 - 09/28 (4)
- ► 09/07 - 09/14 (1)
- ► 07/06 - 07/13 (1)
- ► 06/29 - 07/06 (2)
- ► 05/04 - 05/11 (2)
- ► 01/05 - 01/12 (3)
-
►
2013
(91)
- ► 12/22 - 12/29 (1)
- ► 12/15 - 12/22 (2)
- ► 12/08 - 12/15 (3)
- ► 11/24 - 12/01 (1)
- ► 11/17 - 11/24 (5)
- ► 11/10 - 11/17 (6)
- ► 11/03 - 11/10 (1)
- ► 10/27 - 11/03 (11)
- ► 10/20 - 10/27 (1)
- ► 10/13 - 10/20 (1)
- ► 09/29 - 10/06 (1)
- ► 09/22 - 09/29 (1)
- ► 08/25 - 09/01 (3)
- ► 08/18 - 08/25 (2)
- ► 08/04 - 08/11 (1)
- ► 07/28 - 08/04 (1)
- ► 07/21 - 07/28 (1)
- ► 07/14 - 07/21 (1)
- ► 06/30 - 07/07 (1)
- ► 06/23 - 06/30 (1)
- ► 06/09 - 06/16 (2)
- ► 05/05 - 05/12 (1)
- ► 04/28 - 05/05 (5)
- ► 04/14 - 04/21 (1)
- ► 04/07 - 04/14 (5)
- ► 03/24 - 03/31 (7)
- ► 03/17 - 03/24 (17)
- ► 03/10 - 03/17 (1)
- ► 03/03 - 03/10 (2)
- ► 02/10 - 02/17 (2)
- ► 01/20 - 01/27 (2)
- ► 01/06 - 01/13 (1)
-
▼
2012
(120)
- ► 12/30 - 01/06 (11)
- ► 12/23 - 12/30 (3)
- ► 12/16 - 12/23 (2)
- ► 12/02 - 12/09 (2)
- ► 11/25 - 12/02 (3)
- ► 11/11 - 11/18 (3)
- ► 11/04 - 11/11 (11)
-
▼
10/28 - 11/04
(17)
- Modul Gratis Pemrograman Delphi
- Tutorial Transfer KEY BCA dengan Internet Banking
- Membuat tumbnail pada Delphi
- Menambahkan button didalam DBGRID Delphi
- Delphi 7 Update 1
- FastReport error di Delphi XE2
- Mengenal Turbo Delphi Explorer 2006
- Instal DSPACK di Delphi XE2 32bit
- Instal DSPACK di Delphi 7
- Video capture Delphi Camera client server
- Instal Fast Report Delphi 7
- Instal Qreport atau Quick Report untuk Delphi 7
- Masalah Delphi 7 di Windows 7
- TServerSocket and TClientSocket are Missing from D...
- WMI Delphi Code Creator
- i18n Package
- Delphi7 Lite Edition 7.3.4.3 [2011-08-01] [All Upd...
- ► 10/21 - 10/28 (57)
- ► 10/14 - 10/21 (2)
- ► 10/07 - 10/14 (9)
0 comments: