HTML Color To Delphi TColor
2016-10-10 10:00
183 查看
HTML Color 采用十六进制表示颜色,其格式为RGB,而Tcolor的格式是GBR。如果把HTML颜色转为Tcolor,需要转换其格式。
比如: HTML Color: #123456
转为Tcolor,则为:$563412, 把其转为Integer值,即为Tcolor值。
function TForm1.htmlColor2color( hColor : string ) : Integer;
var
s, c : string;
begin
s := hColor.Trim;
if ( s.Chars[ 0 ] ).IsNumber then
s := s.PadLeft( 6, '0' )
else
s := s.Substring( 1 ).PadLeft( 6, '0' );
// html color : rgb tcolor : gbr
Result := ('$' + s.Substring( 4, 2 ) + s.Substring( 2, 2 ) + s.Substring( 0, 2 )).ToInteger;
end;
以上在 Delphi Berlin 10.1 测试通过。
比如: HTML Color: #123456
转为Tcolor,则为:$563412, 把其转为Integer值,即为Tcolor值。
function TForm1.htmlColor2color( hColor : string ) : Integer;
var
s, c : string;
begin
s := hColor.Trim;
if ( s.Chars[ 0 ] ).IsNumber then
s := s.PadLeft( 6, '0' )
else
s := s.Substring( 1 ).PadLeft( 6, '0' );
// html color : rgb tcolor : gbr
Result := ('$' + s.Substring( 4, 2 ) + s.Substring( 2, 2 ) + s.Substring( 0, 2 )).ToInteger;
end;
以上在 Delphi Berlin 10.1 测试通过。
相关文章推荐
- Convert System.Drawing.Color to HTML color
- Convert CHtmlView to CHtmlCtrl
- Introduction to Design Patterns in Delphi
- How to freeze a dynamic aspx page into a static html page (on the server).
- To select the file to upload we can use the standard HTML input control of type
- Problem Preparation for HTML to TXT
- Delphi to C++Builder v1.5
- http://www.cs.rit.edu/~ncs/color/t_convert.html
- Output ASP.NET Page to HTML
- ASP TO HTML WITH TEMPLATE
- 用HtmlHelp组件在Delphi应用程序中实现Html帮助
- DelphiCodeToDoc--像JavaDoc一样的Delphi源码文档生成工具
- Convert source code to HTML
- delphitimetostring
- Exporting from Crystal Reports to PDF, Word, Excel and HTML
- 简单使用Delphi中的TO-DO List
- [HTML/CSS] Ten ways to speed up the download time of your web pages - Trenton Moss
- 转贴:Conversion to Delphi 6: Missing unit Proxies.pas
- How to sink HTML document events for WebBrowser host -- quoted
- ...append HTML Text to a TWebbrowser Document?