HyperNext Studio

HyperNext Studio => Graphics => Topic started by: tools-n-stuff on October 21, 2010, 06:58:42 PM

Title: User selected image
Post by: tools-n-stuff on October 21, 2010, 06:58:42 PM
I guess hello is the best place to start, so hi to all!

I have to say i have been looking for something like this for around 12 years now.I can do a fair amount of stuff but RAD tools and languages have been a serious issue for me, a total meltdown every time i tried. Ive installed all the MS express stuff, looked at a couple of eclipse packages, looked at realbasic and i just don't get any of it.

Then i came across HN (couple of weeks ago that is), only looked at it 2 days ago though. Since then I think i slept 4 hours in 2 days, this is just too cool. All i have done is open and quickly look at the samples, and finaly settle down and play around with 'BooksHN' adding images, new buttons and textfields and linking them up to store the data.

Theres one thing i could really use some help on though if someone has the time!?

Is it possible to add a button that opens up the C drive so the user can open and place an image next to the comments textfield, maybe/ideally a placeholde image (stored in the template) that can be replaced!?????

I have loads of other questions but im too tired to formulate the words. I'll come back to them after a few hours sleep.

regards
Title: Re: User selected image
Post by: Malkom on October 21, 2010, 09:20:44 PM
Hi and a warm welcome to our forums and I hope you manage to get some sleep very soon.


Quote from: "tools-n-stuff"
Theres one thing i could really use some help on though if someone has the time!?

Is it possible to add a button that opens up the C drive so the user can open and place an image next to the comments textfield, maybe/ideally a placeholde image (stored in the template) that can be replaced!?????

I'm sorry but I'm not sure I understand your question - do you mean an image/icon file and some text that appear when one browses the Windows file system?  - if not please correct me and I'll try answering again.

Yes, its possible to find details of the files on the C drive and so change them but frankly i don't know where the link for the image/icon and text is stored - perhaps its stored invisibly on the root. I guess you can find some info on this by searching the web or by using HyperNext to examine the file system. However, its clearly safer to see some documentation before changing things.

Compared to most HyperNext commands the HyperNext file commands look quite daunting but basically most of the parameters are returned info about the file system being interrogated and they can be simply placed into editfields for examination or ignored if not required.

I hope this helps.

Best regards
Malkom
Title: Re: User selected image
Post by: tools-n-stuff on October 22, 2010, 05:57:42 AM
Hi Malkom and thanks for the welcome,

And now after a few hours sleep im back to realise my message wasn't clear, in fact it was so bad that you completly mis-understood me. Sorry my bad!.

So..........

Normaly the end user can fill in the info about author, title etc etc, i would also like them to be able to import 1 photo per page entry(maybe book cover). This way when they browse, they have all the needed info and a nice photo to look at.

regards
Dayne
Title: Re: User selected image
Post by: Malkom on October 22, 2010, 03:36:49 PM
Hi Dayne

Yes I completely misunderstood.

The command you looking for is:-

Code: [Select]
CanvasLoadAsk(cid,fname,scale)
where:-
   cid - canvas identity - eg 1
   fname - file name retruned by the dialog box
   scale - 0 to leave unchanged, 1 to scale to fit canvas

So to place the selected image in canvas 5 and scale to fit use:-

Code: [Select]
local fname

CanvasLoadAsk(5,fname,1)


Best regards
Malkom
Title: Re: User selected image
Post by: tools-n-stuff on October 22, 2010, 09:19:01 PM
I've got it to work, great, thanks Malkom. Well, almost anyway.

As long as i run it under HN Creator i can hit the button and it will allow me to select and load a file.
If i open a stack with the player it will crash as soon as i hit the button.
Same thing for an .exe file.

Maybe i'm doing something wrong but i can't see what yet.

Any suggestions?

cheers
Title: Re: User selected image
Post by: Malkom on October 23, 2010, 05:39:15 AM
Quote from: "tools-n-stuff"
I've got it to work, great, thanks Malkom. Well, almost anyway.

As long as i run it under HN Creator i can hit the button and it will allow me to select and load a file.
If i open a stack with the player it will crash as soon as i hit the button.
Same thing for an .exe file.

I've just tried under Windows 7 - and the Player and .exe version both work fine for me.

However, on Windows XP as soon as the button is hit my Comodo anti-virus scanner kicks in asking if I want to proceed. Clicking yes then both the stack and .exe work fine.
Perhaps you could check to see if your anti-virus software has Player and your .exe sandboxed so causing them to crash invisibly.
By the way, my Windows 7 also uses Comodo but without a problem when that button is hit.
Title: Re: User selected image
Post by: tools-n-stuff on October 23, 2010, 02:23:39 PM
Hi,
 I'm on vista (can't afford another upgrade yet), and like you i use commodo.  I disabled it just in case and still get the same result. Both the stack and exe file crash when trying to open the drive.
Oh well, not to worry.
Thanks anyway
Dayne
Title: Re: User selected image
Post by: tools-n-stuff on October 23, 2010, 04:50:00 PM
Situation Update:

Ok after further testing, i have now discovered that .stk files do not liked being opened directly by double clicking them. It makes the program crash when the button is pushed.
But if i open the player and the use it to open an stk file then it works just fine. I guess i should be happy with that, and yes i am overjoyed, but i really need the exe file to work as well.
I'll keep you informed and let you know if and how i get it working.
Title: Re: User selected image
Post by: Malkom on October 24, 2010, 11:38:30 AM
Quote from: "tools-n-stuff"
Situation Update:

Ok after further testing, i have now discovered that .stk files do not liked being opened directly by double clicking them. It makes the program crash when the button is pushed.
But if i open the player and the use it to open an stk file then it works just fine. I guess i should be happy with that, and yes i am overjoyed, but i really need the exe file to work as well.

Many thanks for the feedback on this - I'll check this out and see if there is a bug in HyperNext - sounds very much like one.
Title: Re: User selected image
Post by: tools-n-stuff on October 27, 2010, 12:17:26 PM
Within the data store area ( i believe to be used for the end product) are a few files that i can't open, no extension. except  .DS_Store logic which i don't know what to open with either. On testing i now find this file in the Pictures folder.

vvpict_2_3_1

What is this exactly and how do i open it. Can it be removed if not needed.

My reason for this question is that on looking through the the guide to find out more for image saving (canvas graphics, files graphics and image banks) and testing, i am wondering if the above file has appeared in the data/pictures folder because of this or because of the placeholder image on the canvas.

I am basicly trying to get the button to save to the Data/Pictures folder without displaying the option to save elsewhere. Is my code on the right track and could this be the reason for the above file appearing in there.

If you have any thoughts on the following then feel free to help me again.  :)

I have one canvas with three independant button controls.

The 'new' button with
Code: [Select]
local fname

CanvasLoadAsk(1,fname,0)
the save button with
Code: [Select]
local fname

ImageCanvasToBank(1,2,0)
Is this right?

On the other hand the delete button i can't work out through the guide.
I want to be able to remove it from the card/page and from the internal Data storing place. Is that possible?
The reason for this is that i want to be able to run the exe file directly from a 4gig usb data device, so as to stock the info directly to the USB device. (Sorry i only know what they call it in French). Or am i barking up the wrong tree?  :|

Take 2:
Iv'e just found this,

Quote
Clears the image from the specifed image bank so freeing up memory. This also sets the image bank status to invalid.

   ImageBankClear(bid)
obviously i only want to remove the particular image for that page, but still have the option of replacing it. what happens will a new image bank be created?
Title: Re: User selected image
Post by: Malkom on October 27, 2010, 05:55:42 PM
Quote
Within the data store area ( i believe to be used for the end product) are a few files that i can't open, no extension. except .DS_Store logic which i don't know what to open with either. On testing i now find this file in the Pictures folder.

vvpict_2_3_1

What is this exactly and how do i open it. Can it be removed if not needed.

When a picture is loaded into a canvas or dropped onto it HyperNext makes a copy so that when it quits and then restarts it has a copy of the image to reload - the vvpict_2_3_1 is a copy made by HyperNext.




To save an image from a canvas the CanvasJPEGSave will save to a specified local folder.
Note, the final parameter sets the JPEG % quality - 100 is best,  50 is lower etc

Code: [Select]
@ save canvas 1 to the local folder
CanvasJPEGSave(1,picture.jpg,100)

@save Picture to the folder DataPictures
CanvasJPEGSave(1,'DataPicturesPicture.jpg',100)

The ImageBankSave command will also save to a local folder but saves without changing the quality of the image.

Code: [Select]
@save Image Bank 1 to the folder DataPictures
ImageBankSave(1,'DataPicturesPicture.jpg')


Yes, if your exe is on another disk the above code would still save in in the folder or sub-folders of the exe.


The image bank command ImageBankClear(bid) just clears one image in the bank. So if you have an image bank holding 10 images and you clear bank 5, then the other images will remain unchanged. The Imagebank is like an array except it holds images.
Title: Re: User selected image
Post by: sparkythex on December 23, 2010, 05:15:15 PM
i was wondering is there a way to pull file attributes.
using
Code: [Select]
local fname,iheight
CanvasLoadAsk(1,fname,1)

would be looking for something like
     file:///Users/thex/Desktop/my%20mac/my%20doc/my_manga/Iron%20gun/web/pages/picture.jpg
or
    c:mydoc/pages/picture.jpg
Code: [Select]
@find some way to do this.
@because it doesn't work.
put fname into field 1
@ and this
put actualimageheight into field 3
put actualimagewidth into field 4
I really don't need this but it maybe nice to know later.
Code: [Select]
@maybe even this since i have the cavas scaling.
put scaleimageheight into field 5
put scaleimagewidth into field 6
Title: Re: User selected image
Post by: Malkom on December 23, 2010, 08:33:26 PM
Quote from: "sparkythex"
i was wondering is there a way to pull file attributes.
using
Code: [Select]
local fname,iheight
CanvasLoadAsk(1,fname,1)

would be looking for something like
     file:///Users/thex/Desktop/my%20mac/my%20doc/my_manga/Iron%20gun/web/pages/picture.jpg
or
    c:mydoc/pages/picture.jpg
Code: [Select]
@find some way to do this.
@because it doesn't work.
put fname into field 1
@ and this
put actualimageheight into field 3
put actualimagewidth into field 4
I really don't need this but it maybe nice to know later.
Code: [Select]
@maybe even this since i have the cavas scaling.
put scaleimageheight into field 5
put scaleimagewidth into field 6

Its is possible to get some file attributes using the FolderFileDetails command but it cannot return the size of the image as they are contained with the image data.

However, there is an indirect way - load the image into an image bank and read the size of the imagebank.

Code: [Select]
Local pwidth,pheight

@ Clear all image banks
ImageBankReset

@ Reserve space for 1 image
ImageBankReserve(1)

@Load image and scale to full size
ImageBankLoad(1,'picture.jpg',1)

@ Get size of image
Put ImageBankWidthFN(1) into pwidth
Put ImageBankHeightFN(1) into pheight
Title: Re: User selected image
Post by: sparkythex on December 24, 2010, 09:13:13 AM
Quote from: "Malkom"
Its is possible to get some file attributes using the FolderFileDetails command but it cannot return the size of the image as they are contained with the image data.

However, there is an indirect way - load the image into an image bank and read the size of the imagebank.

Code: [Select]
Local pwidth,pheight

@ Clear all image banks
ImageBankReset

@ Reserve space for 1 image
ImageBankReserve(1)

@Load image and scale to full size
ImageBankLoad(1,'picture.jpg',1)

@ Get size of image
Put ImageBankWidthFN(1) into pwidth
Put ImageBankHeightFN(1) into pheight

this requires the path to be known.
what I was after was an image open dialog.
I need the user  to  use a browse button that lets them chose file. or to know the path & put it in a field1 that is for url.
then it would detect that path is valid (probably by lost focus)
it would then load in to the canvas the preview. (it is 100x100)
there are opts for using image default height & width. or setting custom h.& w.
then it would generate html code that would look something like "<img style="width: 576px; height: 737px;" alt="" src="../pages/end.jpg">"
(i wish i could show you a screen shot.)
Title: Re: User selected image
Post by: Malkom on December 24, 2010, 09:56:59 AM
This code will find the full (Absolute) path to a file found by the user via a Dialog box.,
It looks messy but thats because the Dialog Box returns a lot of details about the file.

Code: [Select]
Local fname,fhandle,fdetails,ctypes,cpaths,cnames,fextens
Global fullPathName

@ Get file handle via a Dialog Box
FileAsk(fname,fhandle,fdetails,ctypes,cpaths,cnames,fextens)

Put line 9 of fdetails into fullPathName

Put fullPathName into field 1



The details of a file or folder is returned as a list of attributes separated by carriage returns
(in the above example - line 9 was read in order to get the full pathname)

Code: [Select]
  1    -  Name of file or folder.
   2    -  1 if it exists, 0 otherwise.
   3    -  1 if it is a folder, 0 if a file.
   4    -  1 if an alias.
   5    -  1 if visible.
   6    -  1 if locked.
   7    -  1 if writeable.
   8    -  1 if readable.
   9    -  the absolute path.
   10  -  the number of items in the folder.
   11  -  The Mac Type code.
   12  -  The Mac Creator code.
   13  -  the creation short date.
   14  -  the creation short time.
   15  -  the modification short date.
   16  -  the modification short time.
   17  -  the display name.
   18  -  1 if the extension is visible.
   19  -  the length of the data fork.
   20  -  the length of the resource fork.
   21  -  the Macintosh Directory ID - an integer.
   22  -  the Macintosh VRefNum - an integer.
   23  -  Actual name including extension.
   24  -  filename extension.
   25  -  type (user created ).
   26  -  Parent directory absolute pathname.
Title: Re: User selected image
Post by: sparkythex on January 06, 2011, 06:57:27 AM
well maybe we were thinking backwards on this.
instead of using the open dialog for the image.
the other way around is...
can i use the path from the open dialog to set the field & then that fire to set the image?
since your research says the set cavans doesn't fire back the path.

OH an thank you for enjoying my art.

by the way -- the screen shot was of a card, i was trying to make my own dialog already.

Quote
Date: Thu, 30 Dec 2010 18:36:45 +0100
From: sparkythex@hotmail.com (http://mailto:sparkythex@hotmail.com)
Subject: Re: HyperNext bug

I got a nice suprise - you have some really great images - cartoons on your links.

About your program - unfortunately HyperNext file dialogs do not show the preview of an image - i think you could probably make your own file access with previews using a card, canvas, listbox and initially use the system dialog box to get the folder to browse - sorry its messy - i'll look into a solution for this in HyperNext V4

About setting the page for you depending upon an image.- i've just found a serious bug - when an image is dropped onto a canvas - the canvas event does not fire - this ruins so many things :(
My idea was to drop the image onto the canvas - then the canvas event would fire and allow your code to get image size, re-size canvas, and move canvas to correct postion etc - then you could generate HTML code from this :(

I hope you have a happy New Year, and fun with your programming.



On 12/24/2010 5:10 PM, sparky thex wrote:

    Thanks so much for the help you  have given.
    I really do appreciate it!!!

    Oh and merry Christmas, don't waste to much of it on this!!!

    ================
    what this screen shot shows is the add image card of my app.
    which is not quite an html editor but it is to design a template for a webcomic book that will set up the page for you in a html frame set.
    it also shows a screen shot of an html program i use.

    you can still answer this on the forum but i figured this may make it easier to help you see, what i need to accomplish, or if it can be done.

    -- original post ---

    viewtopic.php?f=17&t=72&p=275#p275 (http://www.tigabyte.com/forums/viewtopic.php?f=17&t=72&p=275#p275)

    this requires the path to be known.
    what I was after was an image open dialog  [[WITH A PREVIEW]] .
    I need the user to use a browse button that lets them chose file. or to know the path & put it in a field1 that is for url.
    then it would detect that path is valid (probably by lost focus)
    it would then load in to the canvas the preview. (it is 100x100)
    there are opts for using image default height & width. or setting custom h.& w.
    then it would generate html code that would look something like "<img style="width: 576px; height: 737px;" alt="" src="../pages/end.jpg">"
    (i wish i could show you a screen shot.)

except i must have missed something because this doesn't load the image & path  looks all weird.
instead of showing all normal like
Code: [Select]
file:///Users/thex/Desktop/my%20mac/my%20doc/my_manga/Iron%20Mistress/web/pages/end.jpgi got
Code: [Select]
Macintosh HD:Users:thex:Desktop:my mac:my doc:my_manga:Iron Mistress:web:pages:end.jpg
Code: [Select]
Local fname,fhandle,fdetails,ctypes,cpaths,cnames,fextens
Local pwidth,pheight
Global fullPathName

@ Get file handle via a Dialog Box
FileAsk(fname,fhandle,fdetails,ctypes,cpaths,cnames,fextens)

Put line 9 of fdetails into fullPathName

Put fullPathName into field 1


@@@@@@@@@
reset sizemsg
@ Clear all image banks
ImageBankReset

@ Reserve space for 1 image
ImageBankReserve(1)

@Load image and scale to full size
ImageBankLoad(1,fullPathName,1)

@ Get size of image
@@ @@ Put ImageBankWidthFN(1) into pwidth
@@ @@ Put ImageBankHeightFN(1) into pheight
@@@@@@@@@@@@@@
@ Open dialog
@FileGet
@CanvasLoadAsk(1,FileGet,1)

@@ @@ put fname into field 1

put 'Page lay out design is for 800 x800.' into mess1
put 'the width is more importaint however do to the size of the frame.' into mess1
put 'You may want to use scaling.' into mess1
put 'NOTE: Picutre size will remain,' into mess1
put 'the same, just displayed smaller.' into mess1
put 'You can use the "open in new page link" option.' into mess1
put 'to allow for viewing in full size.' into mess1

             @@@@ test for pic size.
    put field 3 into ans
if sizemsg>2 or ans>800 then
    @do nothing, assume that warning was seen.
else
    add 1 to sizemsg
    message mess1
endif
@@@@@@@@@
Title: Re: User selected image
Post by: Malkom on January 06, 2011, 01:54:19 PM
Quote from: "sparkythex"

except i must have missed something because this doesn't load the image & path  looks all weird.
instead of showing all normal like
Code: [Select]
file:///Users/thex/Desktop/my%20mac/my%20doc/my_manga/Iron%20Mistress/web/pages/end.jpgi got
Code: [Select]
Macintosh HD:Users:thex:Desktop:my mac:my doc:my_manga:Iron Mistress:web:pages:end.jpg

I'm not sure which platform you are developing on Windows or Macintosh?

The Windows and Macintosh file path separators are "" and ":" respectively.

The first looks like the path given to web browser:-
Code: [Select]
file:///Users/thex/Desktop/my%20mac/my%20doc/my_manga/Iron%20Mistress/web/pages/end.jpg
and the second is Macintosh  full (absolute) file path:-
 
Code: [Select]
Macintosh HD:Users:thex:Desktop:my mac:my doc:my_manga:Iron Mistress:web:pages:end.jpg
Title: Re: User selected image
Post by: sparkythex on January 06, 2011, 05:05:39 PM
Quote from: "Malkom"
I'm not sure which platform you are developing on Windows or Macintosh?

The Windows and Macintosh file path separators are "" and ":" respectively.

The first looks like the path given to web browser:-
Code: [Select]
file:///Users/thex/Desktop/my%20mac/my%20doc/my_manga/Iron%20Mistress/web/pages/end.jpg
and the second is Macintosh  full (absolute) file path:-
 
Code: [Select]
Macintosh HD:Users:thex:Desktop:my mac:my doc:my_manga:Iron Mistress:web:pages:end.jpg

well I am trying to make something cross platform.
I still use both windows & mac so want something that will look very much the same on both.
(only been using a mac for about 2 years so still new to it.)

That is correct am after a web based path, it is in what i wrote  that am working on a online, content generator/ database.  
So the results need to  be something for the web.
I didn't think about that as I every time I used an html editor it just did it that way.  (& of course the file path on windows looks that way too & as well when I opened it in firefox & IE.)
Title: Re: User selected image
Post by: Malkom on January 06, 2011, 07:53:59 PM
Quote from: "sparkythex"
Quote from: "Malkom"
I'm not sure which platform you are developing on Windows or Macintosh?

The Windows and Macintosh file path separators are "" and ":" respectively.

The first looks like the path given to web browser:-
Code: [Select]
file:///Users/thex/Desktop/my%20mac/my%20doc/my_manga/Iron%20Mistress/web/pages/end.jpg
and the second is Macintosh  full (absolute) file path:-
 
Code: [Select]
Macintosh HD:Users:thex:Desktop:my mac:my doc:my_manga:Iron Mistress:web:pages:end.jpg

well I am trying to make something cross platform.
I still use both windows & mac so want something that will look very much the same on both.
(only been using a mac for about 2 years so still new to it.)

That is correct am after a web based path, it is in what i wrote  that am working on a online, content generator/ database.  
So the results need to  be something for the web.
I didn't think about that as I every time I used an html editor it just did it that way.  (& of course the file path on windows looks that way too & as well when I opened it in firefox & IE.)

Thank you for the further explanation - I'm starting to understand now.

To convert the file path to a web format one you could use the ReplaceAll string command but as your app is cross-platform you will need to use the correct path separator depending upon whether your program is running on Macintosh or Windows:-

Code: [Select]
@ assume filePath holds your unprocessed file path
Global filePath

@ get correct path separator for the platform your program is currently on
@ HyperNext automatically returns the correct separator
Local appsep
Put FolderSeparatorFN into appsep

@ replace the app sep with a web based one
Local websep
Put '/' into websep
ReplaceAll appsep with websep in filePath

Of course you will have to convert the start of the file path to a web based one.