ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 TImageEnIO loads GIF file with wrong colors!

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
PeterPanino Posted - Mar 28 2014 : 09:50:42
Hi! I have a TImageEnIO component on a form, where the AttachedTImage property is set to a TImage on the form.

Now I load this GIF file with:
ImageEnIO1.LoadFromFileGIF(test.gif);



However, after loading the TImage looks so:



What is wrong here? How can display the image correctly?
2   L A T E S T    R E P L I E S    (Newest First)
PeterPanino Posted - Mar 29 2014 : 05:46:51
I've found the culprit: When ImageEnIO1.NativePixelFormat = True then the image appears distorted after ImageEnIO1.LoadFromFileGIF(test.gif);.

But the more strange thing is: When I execute this TWICE then the image is not distorted:

ImageEnIO1.NativePixelFormat := True;
ImageEnIO1.LoadFromFileGIF(Edit1.Text); // distorted
ImageEnIO1.LoadFromFileGIF(Edit1.Text); // not distorted

This is really strange! Can anyone explain this?
w2m Posted - Mar 28 2014 : 11:28:36
I do not get the same results that you do.



DFM
object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'TImage Copy and Paste'
  ClientHeight = 337
  ClientWidth = 635
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  OnDestroy = FormDestroy
  PixelsPerInch = 96
  TextHeight = 13
  object Splitter1: TSplitter
    Left = 325
    Top = 32
    Width = 5
    Height = 305
    ExplicitTop = 41
    ExplicitHeight = 213
  end
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 635
    Height = 32
    Align = alTop
    BevelOuter = bvNone
    TabOrder = 0
    object Open1: TButton
      Left = 9
      Top = 3
      Width = 75
      Height = 25
      Caption = 'Open'
      TabOrder = 0
      OnClick = Open1Click
    end
    object Copy: TButton
      Left = 90
      Top = 3
      Width = 75
      Height = 25
      Caption = 'Copy'
      TabOrder = 1
      OnClick = CopyClick
    end
    object Paste1: TButton
      Left = 171
      Top = 3
      Width = 75
      Height = 25
      Caption = 'Paste'
      TabOrder = 2
      OnClick = Paste1Click
    end
  end
  object ScrollBox1: TScrollBox
    Left = 0
    Top = 32
    Width = 325
    Height = 305
    Align = alLeft
    BevelInner = bvNone
    BevelOuter = bvNone
    TabOrder = 1
    ExplicitTop = 41
    ExplicitHeight = 213
    object Image1: TImage
      Left = 0
      Top = 0
      Width = 321
      Height = 301
      Align = alClient
      Picture.Data = {07544269746D617000000000}
      ExplicitLeft = 13
      ExplicitTop = 16
      ExplicitWidth = 105
      ExplicitHeight = 105
    end
  end
  object ScrollBox2: TScrollBox
    Left = 330
    Top = 32
    Width = 305
    Height = 305
    Align = alClient
    BevelInner = bvNone
    BevelOuter = bvNone
    TabOrder = 2
    ExplicitLeft = 331
    ExplicitTop = 41
    ExplicitWidth = 304
    ExplicitHeight = 213
    object Image2: TImage
      Left = 0
      Top = 0
      Width = 301
      Height = 301
      Align = alClient
      Picture.Data = {07544269746D617000000000}
      ExplicitLeft = 13
      ExplicitTop = 16
      ExplicitWidth = 105
      ExplicitHeight = 105
    end
  end
  object ImageEnProc1: TImageEnProc
    PreviewsParams = [prppShowResetButton, prppHardReset]
    PreviewFont.Charset = DEFAULT_CHARSET
    PreviewFont.Color = clWindowText
    PreviewFont.Height = -11
    PreviewFont.Name = 'Tahoma'
    PreviewFont.Style = []
    AttachedTImage = Image1
    Left = 63
    Top = 55
  end
  object ImageEnIO1: TImageEnIO
    PreviewFont.Charset = DEFAULT_CHARSET
    PreviewFont.Color = clWindowText
    PreviewFont.Height = -11
    PreviewFont.Name = 'Tahoma'
    PreviewFont.Style = []
    AttachedTImage = Image1
    Left = 26
    Top = 53
  end
  object OpenPictureDialog1: TOpenPictureDialog
    Left = 28
    Top = 83
  end
  object ImageEnProc2: TImageEnProc
    PreviewsParams = [prppShowResetButton, prppHardReset]
    PreviewFont.Charset = DEFAULT_CHARSET
    PreviewFont.Color = clWindowText
    PreviewFont.Height = -11
    PreviewFont.Name = 'Tahoma'
    PreviewFont.Style = []
    AttachedTImage = Image2
    Left = 230
    Top = 50
  end
end

PAS
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
  Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.ExtDlgs, imageenio, imageenproc, hyiedefs,
  hyieutils {, jpeg, gifimg, pngimage};

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Open1: TButton;
    Copy: TButton;
    Paste1: TButton;
    ScrollBox1: TScrollBox;
    Image1: TImage;
    ImageEnProc1: TImageEnProc;
    ImageEnIO1: TImageEnIO;
    OpenPictureDialog1: TOpenPictureDialog;
    ScrollBox2: TScrollBox;
    Image2: TImage;
    ImageEnProc2: TImageEnProc;
    Splitter1: TSplitter;
    procedure FormCreate(Sender: TObject);
    procedure Open1Click(Sender: TObject);
    procedure CopyClick(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Paste1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.CopyClick(Sender: TObject);
begin
  { Copy image to the clipboard }
  ImageEnProc1.CopyToClipboard(False);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  { Register ImageEn File Formats with TPicture }
  IERegisterFormats;
  OpenPictureDialog1.filter := GraphicFilter(TGraphic);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  { Unregister Picture formats }
  IEUnRegisterFormats;
end;

procedure TForm1.Open1Click(Sender: TObject);
begin
  if OpenPictureDialog1.Execute then
  begin
    { Load an image with ImageEnIO1 attached to Image 1 }
    ImageEnIO1.LoadFromFile(OpenPictureDialog1.FileName);
    ScrollBox1.HorzScrollBar.Range := Image1.Picture.Width;
    ScrollBox1.VertScrollBar.Range := Image1.Picture.Height;
  end;
end;

procedure TForm1.Paste1Click(Sender: TObject);
begin
  { Paste the clipboard to Image2 }
  ImageEnProc2.PasteFromClipboard;
  ScrollBox2.HorzScrollBar.Range := Image2.Picture.Width;
  ScrollBox2.VertScrollBar.Range := Image2.Picture.Height;
end;

end.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Custom ImageEn Development