-1
A
回答
6
procedure TForm1.GenerateImageWithRandomColors;
var
I, J: Integer;
ColorHEX: string;
Bitmap: TBitmap;
JpegImg: TJpegImage;
begin
Randomize;
Bitmap := TBitmap.Create;
try
Bitmap.Width := 100;
Bitmap.Height := 100;
Bitmap.PixelFormat := pf24bit;
for I := 0 to Pred(Bitmap.Width) do
begin
for J := 0 to Pred(Bitmap.Height) do
begin
Bitmap.Canvas.Pixels[I, J] := RGB(Random(256),
Random(256),
Random(256));
// get the HEX value of color and do something with it
ColorHEX := ColorToHex(Bitmap.Canvas.Pixels[I, J]);
end;
end;
JpegImg := TJpegImage.Create;
try
JpegImg.Assign(Bitmap);
JpegImg.SaveToFile('test.jpg');
finally
JpegImg.Free;
end;
finally
Bitmap.Free;
end;
end;
function TForm1.ColorToHex(Color : TColor): string;
begin
Result :=
IntToHex(GetRValue(Color), 2) +
IntToHex(GetGValue(Color), 2) +
IntToHex(GetBValue(Color), 2);
end;
相關問題
- 1. 我無法在delphi中使用jpeg xe2
- 2. 啓用TImage在Delphi XE3中打開JPEG,GIF和PNG?
- 3. 如何使用Delphi編寫超過物理RAM的巨大JPEG?
- 4. 使用Delphi處理大圖像,保存爲.jpeg
- 5. Delphi中使用
- 6. 在Delphi中使用IVirtualDesktopManager
- 7. 在Delphi中使用_set_invalid_parameter_handler
- 8. 在Delphi中使用LocalAsyncVclCall
- 9. 在Delphi中使用SecureZeroMemory
- 10. 在delphi中使用UrlCreateFromPath XE7
- 11. 在C++中使用delphi庫
- 12. 在Delphi中使用指針
- 13. 在C++中使用Delphi DLL
- 14. 在delphi中使用dll ocx
- 15. 在Delphi中使用SNMP
- 16. DbExpress在delphi中的使用
- 17. 如何在Java中使用JPEG-LS
- 18. JPEG和PNG庫在PIL中使用
- 19. 在小冊子中使用jpeg瓷磚
- 20. 的Delphi(X3更大)的JPEG VS .NET(X1小)的JPEG文件大小
- 21. 在Delphi中使用指針調用DLL
- 22. 如何在使用Delphi-Mocks框架的Delphi中的子類中使用mocks
- 23. 在JPEG中將JPEG轉換爲SWF?
- 24. 在Delphi中使用Delphi創建表格和自動增加列
- 25. 在Delphi中使用Delphi XE8實現材質設計主題
- 26. 如何在Delphi 7中使用delphi製作com界面
- 27. 在Delphi中使用PerlRegEx解析文本
- 28. 如何在Delphi中使用Bloomberg API?
- 29. 如何在Delphi中使用宏?
- 30. 如何在Delphi 7中使用chm?
謝謝。我加了var:jpegimg:tjpegimage;現在沒問題,我試了一下。 – 2012-08-01 20:09:32
@keremaybeyaz我編輯了這篇文章。如果我的回答很有用,請將其標記爲正確。 – 2012-08-01 20:11:52
是的,它的工作謝謝agaın.. – 2012-08-01 20:12:00