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
 ImageEn 6.3 Error at runtime

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
yogiyang Posted - Jun 03 2016 : 07:22:38
Hello,

When I am trying to compile the application code using the new version of IE in XE6 I am getting error on line # 15645 in the file imageenview.

Here is the code:
newAlpha.Allocate(oldAlpha.Width, oldAlpha.Height, ie8g);

Why I cannot trace this out... The version 6.2.1 of IE is working properly.

TIA


Yogi Yang
17   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Jun 12 2016 : 19:34:24
Hi Yogi

I appreciate your situation, and apologize for the difficulty. Unfortunately it would not be fair to our other customers to give priority to your bug over others that we must resolve. Generally we will have a fix for this kind of bug within one to two weeks.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
yogiyang Posted - Jun 10 2016 : 23:52:23
Hello Nigel,

I don't want to sound rough but this one thing is stopping us from upgrading our software to the new version of ImageEn and deriving benefits from it. We will have to hold up two new software release till this problem is not solved.

It is an earnest request that if possible please speed up the process of releasing an update for this particular problem.

TIA


Yogi Yang
xequte Posted - Jun 10 2016 : 23:04:00
Thanks, I can reproduce and we will investigate.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
yogiyang Posted - Jun 10 2016 : 04:14:17
Hello Nigel,

Thanks for your patience with my problem.

Actually I am also getting this same error at the same location in the Demo PhotoEn3 when opening PSD files and trying to work in them.

Here is the link to download test case code along with on PSD and a few photos that I am using for testing.

https://www.dropbox.com/s/06sv6by2dh6t45y/PhotoEn3.zip?dl=0

Before compiling the demo you will have to make a few corrections in the code to point it to the director from where it will load photos.

The folder SamplePhotos contains a few photos that I always use for testing.

The folder SamplePSD contains one single psd file.

To generate the error please follow this steps:
  • Run the demo.
  • Open the PSD file provided.
  • Click on any photo to select it (not mask).
  • Now Double Click on a photo in the ImageEnMView below.


The error will pop up.

TIA


Yogi Yang
xequte Posted - Jun 09 2016 : 04:49:11
Hi Yogi

All paint events in ImageEnView call SetLayerMask. But generally the layerMask is nil so it immediately exits.

When you clicked Break on the debugger exception notification above, what line did it break on?


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
yogiyang Posted - Jun 09 2016 : 02:38:38
Nigel,

In my code whenever I execute this: MainForm.ImageEnViewMain.DeSelect;

It always calls SetLayerMask procedure.

I don't know as to why?



Yogi Yang
yogiyang Posted - Jun 09 2016 : 02:11:41
Nigel,

Even this simple code is giving error as the same location.

If you will observe the code there is reference to Mask what so ever yet...

procedure TMainForm.iemPhotosDblClick(Sender: TObject);
var
  LL, LT, LW, LH, NewW, NewH, CurrLayer: Integer;
  FlName: string;
  ieTemp: TImageEnView;
  i: Integer;
  FileFound: Boolean;
begin

  if MainForm.ImageEnViewMain.IsEmpty then
  begin
    exit;
  end;

  if iemPhotos.SelectedImage >= 0 then
  begin
    Screen.Cursor := crHourGlass;

    if MainForm.ImageEnViewMain.CurrentLayer.Locked or
      not MainForm.ImageEnViewMain.CurrentLayer.Visible then
    begin
      ShowMessage('Please select a Valid Photo');      
      exit;
    end;

    CurrLayer := MainForm.ImageEnViewMain.LayersCurrent;
    LL := MainForm.ImageEnViewMain.CurrentLayer.PosX;
    LT := MainForm.ImageEnViewMain.CurrentLayer.PosY;
    LW := MainForm.ImageEnViewMain.CurrentLayer.Width;
    LH := MainForm.ImageEnViewMain.CurrentLayer.Height;

    // Code Added for Inserting Photos on Selected Layer
    ieTemp := TImageEnView.Create(Application);
    ieTemp.LayersAdd;
    // Auto Roted
    ieTemp.IO.Params.JPEG_EnableAdjustOrientation := True;
    // Auto RotedR
    ieTemp.IO.LoadFromFile(iemPhotos.ImageFileName[iemPhotos.SelectedImage]);

    // +++++++++++++++++++++++++++++++++++++
    if ieTemp.Layers[ieTemp.LayersCurrent].Width < LW then
    begin
      if LW > LH then
        ieTemp.Proc.Resample(LW, -1, TResampleFilter(EnlargeFilter))
      else
        ieTemp.Proc.Resample(-1, LH, TResampleFilter(EnlargeFilter));
      if EnlargeSharpenValue > 0 then
        ieTemp.Proc.Sharpen(EnlargeSharpenValue);
    end
    else
    begin
      if LW > LH then
        ieTemp.Proc.Resample(LW, -1, TResampleFilter(ReductionFilter))
      else
        ieTemp.Proc.Resample(-1, LH, TResampleFilter(ReductionFilter));
    end;

    MainForm.ImageEnViewMain.CurrentLayer.Assign(ieTemp.CurrentLayer);
    ieTemp.Free;

    // Save the file to list
    if MainForm.lstLayerFiles.Count > 0 then
    begin
      MainForm.lstLayerFiles.Items[CurrLayer] := iemPhotos.ImageFileName
        [iemPhotos.SelectedImage];
    end;

    MainForm.ImageEnViewMain.CurrentLayer.PosX := LL;
    MainForm.ImageEnViewMain.CurrentLayer.PosY := LT;

    LW := MainForm.ImageEnViewMain.CurrentLayer.Width;
    LH := MainForm.ImageEnViewMain.CurrentLayer.Height;

    MainForm.ImageEnViewMain.Update;

    RefreshControls;
    // Code to update the List Control for the selected image
    try

      FlName := ExtractFileName(iemPhotos.ImageFileName
        [iemPhotos.SelectedImage]);
      for i := 0 to lstPhotoList.Items.Count - 1 do
      begin
        if lstPhotoList.Items[i] = FlName then
        begin
          FileFound := True;
          break;
        end
        else
        begin
          FileFound := False;
        end;
      end;

      if FileFound = False then
      begin
        lstPhotoList.Items.Add(FlName);
      end;

      FlName := ExtractFilePath(iemPhotos.ImageFileName[0]);
      FlName := FlName + PhotoList;

      lstPhotoList.Items.SaveToFile(FlName);

    except
      on E: Exception do
        ShowMessage('Error while updating Photo usage in Database' + #13 +
          E.Message);
    end;

  end;

  MainForm.ImageEnViewMain.MouseInteract := [miMoveLayers, miResizeLayers];
  lblUsedPhotos.Caption := 'Unused : ' +
    IntToStr(iemPhotos.ImageCount - GetUsedPhotos(InputPath));
  Screen.Cursor := crDefault;
end;

TIA


Yogi Yang
yogiyang Posted - Jun 09 2016 : 02:06:36
Nigel,

I will look into that and get back to you.

TIA


Yogi Yang
xequte Posted - Jun 09 2016 : 00:27:13
Hi Yogi

If the memory has been corrupted somewhere, it is not unusual for a change in code to expose it.

On what line of SetLayerMask does the memory arise? Are the variables on that line valid?



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
yogiyang Posted - Jun 08 2016 : 09:41:18
Here are the two error messages...









Yogi Yang
yogiyang Posted - Jun 08 2016 : 08:35:50
Nigel,

May be you are right. But what I don't understand is that my application code compiles and works like a charm in IE 6.2.1 but it givens error in IE6.3.

When I tried to debug the code I kept landing on this code section in ImageEn:
procedure SetLayerMask;
  var
    pold, pnew: pbyte;
    i, j: integer;
    aw, ah: integer;  // alpha width and height
    mw, mh: integer;  // mask width and height
    v: integer;
    rx, ry: double;
    zx, zy: double;
    mx, my: integer;
    mxarr: pintegerarray;
    msk_p: pbytearray;
    l0width, l0height: integer;
    rmy: integer;
    armx: pintegerarray;
    doloop: boolean;
  begin
    if layerMask = nil then
      exit;
    if layer.fCachedLayerMask<> nil then
    begin
      // cached
      oldAlpha := lBitmap.DetachAlphaChannel();
      lBitmap.ReplaceAlphaChannel(layer.fCachedLayerMask);
      newAlpha := layer.fCachedLayerMask;
    end
    else
    begin
      // check pixelformat of layer mask
      if layerMask.Bitmap.PixelFormat <> ie8g then
      begin
        layerMask.Bitmap.PixelFormat := ie8g;
        if layerMask.Bitmap.HasAlphaChannel then
          layerMask.Bitmap.RemoveAlphaChannel;  // a layer mask cannot have alpha channel
      end;

      l0width  := Layers[0].Bitmap.Width;
      l0height := Layers[0].Bitmap.Height;
      oldAlpha := lBitmap.DetachAlphaChannel();
      newAlpha := TIEBitmap.Create;
      newAlpha.Allocate(oldAlpha.Width, oldAlpha.Height, ie8g);
      lBitmap.ReplaceAlphaChannel(newAlpha);
      aw := newAlpha.Width;
      ah := newAlpha.Height;
      mw := layerMask.Bitmap.Width;
      mh := layerMask.Bitmap.Height;
      zx := (layer.Width / layer.Bitmap.Width);
      zy := (layer.Height / layer.Bitmap.Height);
      rx := (layerMask.Width / layerMask.Bitmap.Width);
      ry := (layerMask.Height / layerMask.Bitmap.Height);
      armx := nil;

      getmem(mxarr, sizeof(integer) * aw);
      for j := 0 to aw - 1 do
        mxarr[j] := round((j * zx / rx - layerMask.PosX / rx) + layer.PosX / rx);

      if fSoftCrop = iesfAlphaBlend then
      begin
        getmem(armx, sizeof(integer) * aw);
        for j := 0 to aw - 1 do
        begin
          i := round(mxarr[j] * rx) + layer.PosX;
          if (i < 0) or (i > l0width) then
            armx[j] := 0
          else
            armx[j] := - 1;
        end;
      end;

      for i := 0 to ah - 1 do
      begin
        pold := oldAlpha.Scanline[i];
        pnew := newAlpha.Scanline[i];
        my := round((i * zy / ry - layerMask.PosY / ry) + layer.PosY / ry);
        msk_p := layerMask.Bitmap.Scanline[imin(imax(0, my), layerMask.Bitmap.Height - 1)];
        doloop := true;
        if fSoftCrop = iesfAlphaBlend then
        begin
          rmy := round(my * ry) + layer.PosY;
          if (rmy < 0) or (rmy > l0height) then
          begin
            FillChar(pnew^, aw, fSoftCropValue);
            doloop := false;
          end;
        end;
        if doloop then
        begin
          for j := 0 to aw - 1 do
          begin
            if (fSoftCrop = iesfAlphaBlend) and (armx[j] = 0) then
              v := fSoftCropValue
            else
            begin
              mx := mxarr[j];
              if (my < mh) and (my >= 0) and (mx < mw) and (mx >= 0) then
                v := msk_p[mx]
              else
                v := 0;
            end;
            if pold^ < v then
              pnew^ := pold^
            else
              pnew^ := v;
            inc(pold);
            inc(pnew);
          end;
        end;
      end;
      freemem(mxarr);
      if fSoftCrop = iesfAlphaBlend then
        freemem(armx);
    end;
  end;


TIA


Yogi Yang
xequte Posted - Jun 06 2016 : 20:28:13
Hi Yogi

I've checked the commits and there should be no code changes to allocate() between 6.2.1 and 6.3.0. Perhaps the memory is being trashed somewhere? I suggest you try stepping into the ImageEn code to see if that gives you some hint.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
yogiyang Posted - Jun 06 2016 : 03:55:51
I have not tested it in any of your demos.

Actually the process is a complicated. We are loading two different PSD one after the other and preserving the layers. Till here things are working properly.

After this we loop through all the layers and find the layers that are landscape and load all the landscape user selected photos on each found landscape layer.

Next we reiterate all portrait and do the same.

In between various operation we have inserted a few Application.ProcessMessages. This we had to do because when we put any progress message in a Label it is not getting updated in real time so we have to call Application.ProcessMessages so that the label is updated with new message.

We reiterate through all layers and lock all those layers on which user selected photos are not loaded.

And it is here that the app goes into some kind of infinite loop when we run the executable stand alone. There are not error messages displayed what so ever.

If we run the code in Debug mode in IDE when we reach to this code fragment it shows error message and when we break it always breaks on this line: newAlpha.Allocate(oldAlpha.Width, oldAlpha.Height, ie8g);

TIA


Yogi Yang
xequte Posted - Jun 06 2016 : 03:11:59
Hi Yogi

There are no outstanding PSD issues that we are aware of. Are you able to reproduce this in any of our demos?



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
yogiyang Posted - Jun 06 2016 : 01:56:08
There are no error messages.

The application just hangs when we are loading various PSD files (when we are running it stand alone) and on debugging it in the IDE show multiple error messages and on break it is always stopped at line as posted in my initial post.

TIA


Yogi Yang
xequte Posted - Jun 04 2016 : 17:08:12
Hi Yogi

What is the error that you get?

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
yogiyang Posted - Jun 03 2016 : 08:19:56
I want to mention that if we create a new app from scratch then I am not getting this error.

The application in question is quite huge, around 100K lines of code so tracking the problem is a bit too hard...



Yogi Yang