JPEG ve TIFF (başka verilerle birlikte) görüntü yönünü belirtmek Exif (Değiştirilebilir görüntü dosya biçimi) meta veriler.
O "TImage Resmimi dönen" değil. TImage, Exif yönelim meta verilerini işlemiyor. İdeal olarak, TImage oryantasyon meta verilerine göre görüntüyü otomatik döndürmek gerekir, ancak öyle değil. Exif yönelim özelliğini okumalı ve resmi buna göre döndürmelisiniz.
Exif tag "Oryantasyon" (0x0112) spec:
1 = Horizontal (normal)
2 = Mirror horizontal
3 = Rotate 180
4 = Mirror vertical
5 = Mirror horizontal and rotate 270 CW
6 = Rotate 90 CW
7 = Mirror horizontal and rotate 90 CW
8 = Rotate 270 CW
Bazı ücretsiz Exif components böyle TExif/NativeJpg/CCR Exif kullanabilir ve oryantasyon etiketine göre gerekirse görüntüyü döndürebilirsiniz.
uses GDIPAPI, GDIPOBJ;
procedure TForm1.Button1Click(Sender: TObject);
var
GPImage: TGPImage;
GPGraphics: TGPGraphics;
pPropItem: PPropertyItem;
BufferSize: Cardinal;
Orientation: Byte;
RotateType: TRotateFlipType;
Bitmap: TBitmap;
begin
GPImage := TGPImage.Create('D:\Test\image.jpg');
try
BufferSize := GPImage.GetPropertyItemSize(PropertyTagOrientation);
if BufferSize > 0 then
begin
GetMem(pPropItem, BufferSize);
try
GDPImage.GetPropertyItem(PropertyTagOrientation, BufferSize, pPropItem);
Orientation := PByte(pPropItem.value)^;
case Orientation of
1: RotateType := RotateNoneFlipNone; // Horizontal - No rotation required
2: RotateType := RotateNoneFlipX;
3: RotateType := Rotate180FlipNone;
4: RotateType := Rotate180FlipX;
5: RotateType := Rotate90FlipX;
6: RotateType := Rotate90FlipNone;
7: RotateType := Rotate270FlipX;
8: RotateType := Rotate270FlipNone;
else
RotateType := RotateNoneFlipNone; // Unknown rotation?
end;
if RotateType <> RotateNoneFlipNone then
GPImage.RotateFlip(RotateType);
Bitmap := TBitmap.Create;
try
Bitmap.Width := GPImage.GetWidth;
Bitmap.Height := GPImage.GetHeight;
Bitmap.Canvas.Lock;
try
GPGraphics := TGPGraphics.Create(Bitmap.Canvas.Handle);
try
GPGraphics.DrawImage(GPImage, 0, 0, GPImage.GetWidth, GPImage.GetHeight);
Image1.Picture.Assign(Bitmap);
finally
GPGraphics.Free;
end;
finally
Bitmap.Canvas.Unlock;
end;
finally
Bitmap.Free;
end;
finally
FreeMem(pPropItem);
end;
end;
finally
GPImage.Free
end;
end;
bu bile Windows Explorer her zaman olur bkz:
İşte GDI + (VCL/Windows) kullanarak bir örnek örn olduğunu. Oldukça emin resmin kendisi, bayraklar, "döndürülmüş" olarak ya da bu doğrultuda bir dosyayı şey ile ilgisi vardır. –