Compiling err with images

Asked by Tanvir on 19 Aug 2012
Latest activity Answered by Image Analyst on 19 Aug 2012

I have matlab gui that uses a splash screen using splash function... The gui worked very well inside matlab but after compiling i get an error,which says 'theimage.png' does'nt exist...please help me out

Tanvir

Products

No products are associated with this question.

2 Answers

Answer by Walter Roberson on 19 Aug 2012

Did you "add" the .jpg to the executable? You need to specifically tell the builder to include it along with the executable.

See also the documentation for ctfroot

0 Comments

Walter Roberson
Answer by Image Analyst on 19 Aug 2012

When after compiling? Right after you compile it? Or when you run the program. I'll assume you mean when you try to run the compiled app. You should specify the full path of the image, and check if it exists so that your app doesn't crash:

folder = 'C:\WhateverFolderYouWant'
baseFileName = 'theimage.png';
fullFileName = fullfile(folder, baseFileName);
if exist(fullFileName, 'file')
  % Found splash image, so display it.
  splashImage = imread(fullFileName);
  imshow(splashImage);
else
  % Didn't find it there, so now look in the current folder.
  folder = pwd;  % This should be the same as ctfroot if you just started the app.
  fullFileName2 = fullfile(folder, baseFileName);
  if exist(fullFileName2, 'file')
    message = sprintf('Warning: could not find splash image:\n%s or \n', ...
    fullFileName, fullFileName2);
    uiwait(warndlg(message));
  end
end  

At least this code will tell you where the program is looking for the spalsh image file. I think you probably shipped the file and saved it in the same folder as the executable, but you don't realize that the executable is not the real executable and that it's just an archive. It runs that exe and unpacks the real exe to some secret folder - ctfroot. You can put ctfroot on its own line or in a fprintf statement to find out where it hid your real executable. You would have to put your executable there, if you installed it yourself, or else use deploy tool and make sure you bundle that image in with your executable so that it will find it in the ctfroot folder. I know, I know - it's confusing. I don't know why they do it that way but they do.

0 Comments

Image Analyst

Contact us