Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Anyone fancy a REAL challenge? (Image Magick)

Author
Message
Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 21st Nov 2007 09:46 Edited at: 21st Nov 2007 10:08
I think you may need to add an extra ',1' on the end of the load image command to use the image properly within a memblock.

That said, to get an image in and out doesn't need to be that complicated - these four lines should create a new image object, fill it with a .bmp from your project folder, flip it, and save it as a .jpg back to your project folder:



It also appears that a URL can be a relative path to a file on your local machine - so the 'NewImageFromURL' command can also be used. As this creates the new image object for you, rather than having to create a new image object first as you do with the Read ImageFromFile command, you can actually save a line of code doing it like this:



Vidiot
17
Years of Service
User Offline
Joined: 15th May 2006
Location: TN
Posted: 21st Nov 2007 17:13
Ok on the "1" texture flag missing. I usually do forget that until something goes wrong...

Yes, it seemed overly complicated because when I tried ReadImageFromFile, it failed. I didn't know I needed to do "Image1=NewImage()" first or that I could without the geometry. Very Good, that simplifies things a lot.

One more question: without writing the image out to disk, is there a simpler way to move images back and forth between DBPro and ImageMagick than the memblock? If I use DBPro's FileBlock commands, I assume it would end up on the windows swapfile anyways, don't know though.

The answer to Life, the Universe, and Everything? "Tea for Two". Deep Thought was Dyslexic.
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 21st Nov 2007 19:19
Also, there is PingImage...(I think), which will give you the size of the image without reading the whole file.

I am not aware of another method for transferring things between DBPro and other code, except for a memory copy of some sort. While it is onerous to code, it runs pretty fast.

ReadImage isn't a constructor. I know it should be, but it is a member function of the Image class. That way you can read an image in over another one using the same image object. I could probably make it that way, but...it would differ from the API too much for my liking.

URLs can refer to any sort of file, not just Internet-delivered ones. ImageMagick is very Unix/Linux biased, so the concept of URLs is somewhat more broad than we are accustomed to.

I used the ImageMagick help to create most of my help files, and it is a good idea to download the ImageMagick docs. I used ImageMagick++, and the help files have some samples...they are trivial, and useless....except to demonstrate use of the API.

btw, I like your siggy.
Vidiot
17
Years of Service
User Offline
Joined: 15th May 2006
Location: TN
Posted: 22nd Nov 2007 02:31
Actually, the idea of loading an image of a remote webpage brings up all sorts of new ideas for my digital signage app. Cool feature!

I might try using a ramdisk as a way to pass a temp file back and forth. It would probably be just as fast and would likely be easier than the memblock.

You're the first person to comment on the siggy. With all the references I see on the net to "42", I'm suprised nobody else mentioned it.

Thanks again jinzai for all your hard work on this. Its greatly appreciated!!!

The answer to Life, the Universe, and Everything? "Tea for Two". Deep Thought was Dyslexic.
Vidiot
17
Years of Service
User Offline
Joined: 15th May 2006
Location: TN
Posted: 25th Nov 2007 07:30
I have a bug and a question...

When I try:
a = TransformImageUsingX11Spec1(Image1,"720x540>")
It fails during compile with: Subscript must be integer or DWORD when referencing an array. I think its not being recognized as a command since it obviously thinks "TransformImage..." is the name of an array.

a = TransformImageUsingX11Spec2(Image1,"720x540>","")
The program runs but fails to resize to the specified size. No error reported.

I also tried:
Geometry1 = NewGeometryFromX11Spec("720x540>")
a = TransformImageUsingGeometry1(Image1,Geometry1)
I get a runtime error: Could not find function 'TransformImageUsingGeometry1@@YAHHH@Z' in 55:jzImageMagick.dll

Update: I just got 'TransformImageUsing' to work with X11Spec, but not X11Spec1 or X11Spec2 as in the doc.

The followup question would be: What is an X11Spec Crop Geometry?

The answer to Life, the Universe, and Everything? "Tea for Two". Deep Thought was Dyslexic.
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 27th Nov 2007 16:14
I do not believe that those other two are even in there at all yet. I will check it out. Sometimes, I forget the question mark in the string resource, leaving the function abandoned in the plug-in.

The crop geometry is the size and offset of the part of the image you are going to remove (to save, that is.).

If you want error to be reported, you need to use the 'verbose' mode, which should give you a message box if ImageMagick fails.
Vidiot
17
Years of Service
User Offline
Joined: 15th May 2006
Location: TN
Posted: 28th Nov 2007 06:47
I finally came accross the ScaleImageUsing functions yesterday which is what I was trying to do with TransformImageUsing anyway.

Thanks for the tip on verbose. Tonight, I tried another thing you mentioned earlier. NewImageFromURL.



Even with my firewall shut down, this fails immediately as if NewImageFromURL() wont wait any time at all time for a reply from a website. Should there be a param to tell this function how long it could wait for a reply?

Thanks Again. I've already put together a utility for my coworkers using some of the functions in this set.

The answer to Life, the Universe, and Everything? "Tea for Two". Deep Thought was Dyslexic.
Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 28th Nov 2007 08:59
The url has to contain the path to a valid image file, not just a website. eg.



works fine here. It does cause my firewall to pop up and ask me if I want to block/allow the download, but that is a good thing.

jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 28th Nov 2007 17:07
Vidiot, there are some http functions in a Windows dll (winhttp)that will let you get an entire webpage. (I am thinking of your digital signage app here.) I did that a few months back, and also...its been done a few times already.

I did not check those functions, but...one of them must have a bad string. I was trying to fake an overloaded function with the "1", "2" suffixes. I will check them tonight...I hope. I just got a wireless USB joystick, and I am busy playing with that. In fact, it make a great object manipulation tool almost straight out of the box! Hmmm.
Vidiot
17
Years of Service
User Offline
Joined: 15th May 2006
Location: TN
Posted: 28th Nov 2007 20:40
I was thinking how cool it would be to be able to grab a portion of a webpage from www.weather.com and composite it with a background image without first having to show it on the screen. I will have to look into this further.

@Ric, Oh I didn't get that. I thought it was going to generate a snapshot of the entire page. That makes sence.

The answer to Life, the Universe, and Everything? "Tea for Two". Deep Thought was Dyslexic.
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 1st Dec 2007 23:28
...then have a look at HowDo's One Wire Weather Station thread. I've gotta run...sorry!

Login to post a reply

Server time is: 2024-05-04 17:21:31
Your offset time is: 2024-05-04 17:21:31