Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Graphics and Multimedia
»
Graphics
»
BGRABitmap and LazPaint
»
Convert BGRAbitmap to 256 Color BMP and save
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
web development using pas...
by
Nate897
[
Today
at 02:04:05 am]
questionable function def...
by
440bx
[
Today
at 01:35:28 am]
Why isn't TTIRadioGroup's...
by
jamie
[
Today
at 12:13:45 am]
Generics - correct syntax
by
jamie
[
Today
at 12:11:50 am]
Offical launch of the 1 B...
by
BeniBela
[
Today
at 12:10:59 am]
Same project and two Pcs
by
caiov1n1c1us
[
Today
at 12:04:00 am]
Copyrights Q
by
440bx
[April 22, 2024, 11:42:21 pm]
v3.99 code completion que...
by
440bx
[April 22, 2024, 11:08:26 pm]
add new targets to make
by
marcov
[April 22, 2024, 09:32:20 pm]
[SOLVED]RichMemo StringRe...
by
KodeZwerg
[April 22, 2024, 08:44:40 pm]
[SOLVED] LAMW/Linux - Ins...
by
Alcatiz
[April 22, 2024, 08:04:06 pm]
[SOLVED] TimeStampToMSecs...
by
korba812
[April 22, 2024, 06:23:33 pm]
Quirky windows
by
ASerge
[April 22, 2024, 06:23:20 pm]
Access violation when re-...
by
cdbc
[April 22, 2024, 05:39:59 pm]
trunk compiler bug for mi...
by
nickysn
[April 22, 2024, 04:05:11 pm]
FPDebug: Evaluate/Modify ...
by
bpranoto
[April 22, 2024, 03:14:12 pm]
Your best UI design - con...
by
lainz
[April 22, 2024, 02:28:00 pm]
Access violation when ope...
by
Чебурашка
[April 22, 2024, 02:07:58 pm]
Unlocking Files
by
KodeZwerg
[April 22, 2024, 12:39:53 pm]
[SOLVED] what is function...
by
Martin_fr
[April 22, 2024, 12:14:59 pm]
[SOLVED] how to build the...
by
Laksen
[April 22, 2024, 10:45:18 am]
AI, NLP and CAI: Text Gen...
by
Dzandaa
[April 22, 2024, 10:33:15 am]
Database standards OR Am ...
by
MarkMLl
[April 22, 2024, 10:22:34 am]
insert select from - with...
by
rvk
[April 22, 2024, 09:55:04 am]
[Solved] Elevated running...
by
AlexTP
[April 22, 2024, 09:40:28 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Convert BGRAbitmap to 256 Color BMP and save (Read 553 times)
winni
Hero Member
Posts: 3197
Convert BGRAbitmap to 256 Color BMP and save
«
on:
November 17, 2022, 02:08:35 pm »
Hi!
Question in the german forum:
How to convert BGRAbitmap to a 256 Color BMP and save it?
It is needed by some SAP software that rejects all images except 256-Color-BMP.
Is there a solution yet? I have not found anything.
Winni
Logged
paweld
Hero Member
Posts: 1003
Re: Convert BGRAbitmap to 256 Color BMP and save
«
Reply #1 on:
November 17, 2022, 05:13:52 pm »
Hi,
sample code:
Code: Pascal
[Select]
[+]
[-]
uses
BGRABitmap
,
BGRABitmapTypes
,
BGRAColorQuantization
,
FPWriteBmp
;
procedure
TForm1
.
Button1Click
(
Sender
:
TObject
)
;
var
img
:
TBGRABitmap
;
bmpw
:
TFPWriterBmp
;
quant
:
TBGRAColorQuantizer
;
i
:
Integer
;
begin
img
:
=
TBGRABitmap
.
Create
(
'd:\wzor80.jpg'
)
;
bmpw
:
=
TFPWriterBmp
.
Create
;
bmpw
.
BitsPerPixel
:
=
8
;
//bmpw.RLECompress := True;
quant
:
=
TBGRAColorQuantizer
.
Create
(
img
,
acIgnore
,
256
)
;
//reduce color to 256 without alfa
quant
.
ApplyDitheringInplace
(
daNearestNeighbor
,
img
)
;
img
.
UsePalette
:
=
True
;
img
.
Palette
.
Clear
;
for
i
:
=
0
to
quant
.
ReducedPalette
.
Count
-
1
do
//copy reduced colors to palette
img
.
Palette
.
Add
(
quant
.
ReducedPalette
.
Color
[
i
]
.
ToFPColor
)
;
img
.
SaveToFile
(
'd:\wzor80_256color.bmp'
,
bmpw
)
;
//save as bmp
bmpw
.
Free
;
//clean
img
.
Free
;
quant
.
Free
;
end
;
Logged
Best regards / Pozdrawiam
paweld
winni
Hero Member
Posts: 3197
Re: Convert BGRAbitmap to 256 Color BMP and save
«
Reply #2 on:
November 17, 2022, 05:37:06 pm »
Hi!
Thanx a lot.
The Quantizer was the part that I forgot. Getting old ...
The Link in the german forum:
https://www.lazarusforum.de/viewtopic.php?f=18&t=14593&p=131460#p131460
Winni
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Graphics and Multimedia
»
Graphics
»
BGRABitmap and LazPaint
»
Convert BGRAbitmap to 256 Color BMP and save
TinyPortal
© 2005-2018