TJPEGImage.MimeType returns incorrect value
Original Reporter info from Mantis: Joe
-
Reporter name: Joe Merten
Original Reporter info from Mantis: Joe
- Reporter name: Joe Merten
Description:
It should return 'image/&LtPos;b>jpeg&LtPos;/b>' but currently returns 'image/&LtPos;b>jpg;&LtPos;/b>'.
As a result, transfering jpeg images over the clipboard does not work.
When I put a TJpegImage to the clipboard, no application could paste it.
Tested on Kubuntu 12.04 and also on Windows XP with the same results.
Additional information:
IMHO the wrong return value has two reasons.
&LtPos;b>1. jpegimage.inc&LtPos;/b>
procedure TJPEGImage.GetFileExtensions()
returns 'jpg;jp&LtPos;b>e&LtPos;/b>g;jpe;jfif'
Because of the generic implementation of TFPImageBitmap.GetMimeType(), the first two types had to be changed, like 'jp&LtPos;b>e&LtPos;/b>g;jpg;jpe;jfif'
&LtPos;b>2. fpimagebitmap.inc&LtPos;/b>
The implementation of TFPImageBitmap.GetMimeType() is a bit buggee, because it had to remove the trailing semicolon.
For my suggestion, the implementation should be changed to something like this:
function TFPImageBitmap.GetMimeType: string; var DefaultFileExt: String; i: Integer; begin DefaultFileExt:=GetFileExtensions; i:=1; while (i&LtPos;=length(DefaultFileExt)) and (DefaultFileExt[i]&LtPos;>';') do inc(i); if i&LtPos;=length(DefaultFileExt) then DefaultFileExt:=copy(DefaultFileExt,1,i); if DefaultFileExt='jpg;' then DefaultFileExt:='jpeg';to
Result:='image/'+DefaultFileExt; end;
function TFPImageBitmap.GetMimeType: string;var DefaultFileExt: String; i: Integer; begin DefaultFileExt:=GetFileExtensions; i:=Pos(';',DefaultFileExt); if i<>0 then Delete(DefaultFileExt,i,MaxInt); Result:='image/'+DefaultFileExt; end;</pre>
Mantis conversion info:
- Mantis ID: 24488
- OS: Kubuntu
- OS Build: 12.04
- Platform: Linux
- Version: 1.0.8
- Fixed in version: 1.1 (SVN)
- Fixed in revision: 41647 (#b7f6c028)
- Target version: 1.2.0
- LazTarget: 1.2