dzImage Library

dzt

Active Member
Licensed User
Hi all,

This is my Image Library for Device and Desktop. Short description follows.

Methods:
ScreenCapture: Captures the whole screen.
ScreenCapture2(x,y,width,Height): Captures part of the screen.
ControlCapture(ControlName,x,y,width,Height): Captures part of a control. x,y are relatives to control upper left corner. The control can be a form or any other control
SaveImageBMP(Image, FileName): Saves the Image as BMP to a file with filename Filename.
SaveImageJPEG(Image, FileName): Saves the Image as JPG to a file with filename Filename.
SaveImageGIF(Image, FileName): Saves the Image as GIF to a file with filename Filename.
CopyImage(sourceImage, x,y,width, height): Copies a part of an image. Returns the new cropped Image (part of the source)
RotateImage(sourceImage, angle): Rotates an image. Angle can be one of 0, 90, 180, 270. Returns the rotated Image
ZoomImage(sourceImage, Percent): Zoomes an image Percent% of the original (Percent = 0 to 1000). Returns the Zoomed Image
ImageSize(Image): Returns an array(2) containing width and height of the image. array(0) = width and array(1) = height

Properies:
Image: The recently captured image

For how to use it see the included in the attached zip, test2.sbp
 

Attachments

  • dzImage.zip
    11.5 KB · Views: 615

alfcen

Well-Known Member
Licensed User
Longtime User
Yasou Dimitris,

You continue amazing me !
Indispensable for astronomy applications that need to adjust star charts and
planet surface views to simulate different optical systems.

I guess the next version will include

1. MirrorUpDown
2. MirrorLeftRight
3. InvertImage

No, no, please, don't amaze me again :)

Happy Holidays!
Robert

Supplement:
I had some fun 'playing' with dzImage :)
No problems encountered, except for RotateImage angle = 0 blacks the form out,
but can be worked around by rotating the source of dr.Image 90 degs every time.
Can't play around any longer, today's my turn for cooking.

Thanks a lot for the new jewel!

Robert
 
Last edited:

dzt

Active Member
Licensed User
Thank you guys for your kind words.

Yes Erel I forgot it. Requires .NET 2.0 (.NETCF 2.0 for the device)

Robert your wishes is an order for me.:)

New version with:

New Methods:
FlipHorizontal(sourceImage): Flips Horizontal the image
FlipVertical(sourceImage): Flips Vertical the image
InvertImage(sourceImage): Inverts the colours of the image

Changed Property:
Image: The Image property is not any more ReadOnly. You can also use it to store an Image

See included FlipInvert.sbp

Happy Holidays to all!
 

Attachments

  • dzImage_02.zip
    12.2 KB · Views: 200

dennishea

Active Member
Licensed User
@dzt

Your having way too much fun. Even though I haven't needed it yet, when I get there I'm problably going to. You make erel's already great program even greater along with a few other members of this forum.
 

alfcen

Well-Known Member
Licensed User
Longtime User
Haisai Dimitris,
Agijabiyo, I was afraid you would do that. :rolleyes:
The good thing about you is, you keep me away from the streets.
Fantastic, entirely new perspectives for image presentations.
It's nearly 2:00AM on this island. I will feed you back any findings, shortly,
if any.
Thanks so much!
Robert
 

derez

Expert
Licensed User
Longtime User
map as an image

hi Dimitris
Your library is expanding the capabilities of this software in steps too large for me ! its fantastic.

If I want to know the size of a jpg file which I display on a form using form.DrawIimage - how do I do it ? (the file size is bigger than the screen, lets say 1000X1000).
The Imagesize gives me the size of the screen and I need the size of the original image file.
If your library can work on the whole image - it will be very useful for my navigation program.

Maybe there is a way to know the properties of an image file even before drawing it on the form.
 

dzt

Active Member
Licensed User
Hi David,

You should load the big image somewhere. An ImageList, a hidden Image control, a hidden form or something. After that you can get it's size using dzImage.ImageSize.

Then you can draw the part of it you want using dzImage.CopyImage
 
Last edited:

derez

Expert
Licensed User
Longtime User
Thank for the idea.
I could not resist and went directly to upgrade my navigation program - to enable the user to rotate the map.
Amazing - it was very easy, after you did all the work in the library.
I also managed to correct some aspect ratio problems :sign0060:

I attach pictures of the screen with the 4 rotation states.

I am very excited about it, thank you again :sign0188:
 

Attachments

  • north_1.JPG
    north_1.JPG
    76.7 KB · Views: 99
  • east_1.JPG
    east_1.JPG
    73.1 KB · Views: 43
  • west_1.JPG
    west_1.JPG
    73.4 KB · Views: 48

alfcen

Well-Known Member
Licensed User
Longtime User
Hello David,
The aspect is not a 'problem', it's a feature. You can use it for image
processing, in this very case, a blur effect. You set the blur factor
simply by the number of rotations using 90 or 270 degrees :)
 

derez

Expert
Licensed User
Longtime User
Features

I like your attitude to problems.
I thought that if the user is in a hurry - he can display the map shrinked in the going direction and thus arrive earlier...;)
 

alfcen

Well-Known Member
Licensed User
Longtime User
That's exactly the idea. Glad we share the same sense of humor.
Best luck with your project, David.
 

derez

Expert
Licensed User
Longtime User
Size

Dimitris

I succeeded also in getting the size of the map by adding it to an ImageList, like you said :)
Thanks again.

your next challenge is to make the rotation for an arbitrary angle...:signOops:
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Hello dzt
I have tried the dzImage.dll great job.
I encountered a problem which happens also in your test2.sbp program
if in line 39 you change
dr.ScreenCapture2(10,10, 100, 100)
to
dr.ScreenCapture2(10,10, 99, 100)
I get an error.
The same happens with
dr.ControlCapture("Button1", 0,0,Button1.Width, Button1.Height)
if you set the Button1.Width to less then 100

It seems that both functions don't accept Widths less than 100.

Can you please check it.

Do you intend to add SaveICO for icons.
And why not LoadICO ?
I would be interested in because I am writing an Icon Editor.
I just added a screenshot that shows the beginning, I ditn't add the code because there is still a lot to add and test.

Thank you in advance
Klaus
Switzerland
 

Attachments

  • IconEdit.jpg
    IconEdit.jpg
    28.3 KB · Views: 39
Last edited:

dzt

Active Member
Licensed User
Hi,

The third version of dzImage is here.

Corrected the problem pointed by Klaus (thank you) regarding Capture2 and ControlCapture when Width < 100

Added some new methods.
ImageToByteArray(Image): Returns an array of bytes which contains the whole Image.
ByteArrayToImage(byte()): Converts the valid (must be) byte() to an Image.
GetPixel(X, Y): Returns a Dim Type(Alpha, Red, Green, Blue) with the attributes of the internal stored image's piointed pixel.
SetPixel(X, Y, Alpha, Red, Green, Blue): Set the pixel in postion X,Y of the internal stored image to Alpha, Red, Green, Blue.

And a modification.
RotateImage(Image, angle) can now accept any angle (be careful of the image size, because angles different from 90, 180, 270 makes this method acting slowly)

In the attached sip is included a sample showing the new additions.

EDIT:
Next Year :) I'll try to make GetPixel and SetPixel much faster (RotateImage too as it is based on them)
 

Attachments

  • dzImage_03.zip
    12.8 KB · Views: 99
Last edited:

derez

Expert
Licensed User
Longtime User
Rotation

Thanks for the effort, but I found it unusable for my program because it is doing the rotation but it takes a lot of time (as expected).
The problem is that I understand the difficulties but I also have an application that does it in real time and I don't know how the creator of that application did it :confused:
 

derez

Expert
Licensed User
Longtime User
Also due to different distance between pixels in x and y, when rotated the result image is distoted in angles. see the example , where I took just part of the whole form and rotated it.
 

Attachments

  • rot.JPG
    rot.JPG
    25.2 KB · Views: 55

dzt

Active Member
Licensed User
Hi,

Attached is the forth version of dzImage.

Added:
FastGetPixel, FastSetPixel, FastRotateImage

For how to use them see the included in the zip sample.
Next Update (if there will be) at 2008 for shure.

The problem is that I understand the difficulties but I also have an application that does it in real time and I don't know how the creator of that application did it

You should realize that we both do not use the fastest development tools and technologies available.

Also due to different distance between pixels in x and y, when rotated the result image is distoted in angles. see the example , where I took just part of the whole form and rotated it.

Your rotated image is wider than your form. So it is displayed distorted. Try DrawImage or use an Image Control.
 

Attachments

  • dzImage_04.zip
    24.3 KB · Views: 97

alfcen

Well-Known Member
Licensed User
Longtime User
Hi David,
As far as I am aware, commercial GPS maps are vector graphics that can
be stretched virtually indefinitely. Rotation angles on bitmaps other than
quarters need adjustment, especially for text. A true challenge, indeed.

Haisai Dimitris,
Congrats! Your latest 'magic' adds further, indispensable value to Basic4ppc.
I have already constructed a viewer application for sky photos including a
magnifying glass on selected coordinates. Of course, it also flips and flops,
rotates, zooms in and out. Reminds me on those days with VB3.0 and BitBlt.

Works lovely and I have encountered just three minor findings (errors
inherent to human programmer can not be excluded):

1. Rotation Angle 0 blacks out the screen or image control.
2. While running fine in the IDE, the exe sometimes prompts
"Invalid Pixel Format" error upon InvertImage.
3. Also upon Invert, the desktop shows correct, while the device does
not invert (perhaps I am seeing things the wrong way round).
I have a master image in an Image Control (mode = cNormalImage) and draw
a manipulated image on a form using DrawImage or to another Image Control.

All can be worked around fairly easily. Since 2007 is fading into history,
let's preserve this issue for 2008 ;)

Thanks so much for this wonderful year-end present!
Cheers
Robert
 

dzt

Active Member
Licensed User
I would be interested in because I am writing an Icon Editor.
I just added a screenshot that shows the beginning, I ditn't add the code because there is still a lot to add and test.

Looks like a professional job. I thinks that my friend Robert (alfcen) finally found a competitor in design skills.:)

Do you intend to add SaveICO for icons.
And why not LoadICO ?

You can load an Icon using LoadPicture of various controls (Image, Form etc.)
To save an Icon you need deep knowledge of the ico format. Take a look at this thread http://www.b4x.com/forum/showthread.php?t=585

dzImage.ImageToByteArray might can help. The first 54 bytes are BITMAPINFOHEADER (40 bytes) and BITMAPFILEHEADER (14 bytes. Next bytes represents the actual image. Take a look here
http://www.fortunecity.com/skyscraper/windows/364/bmpffrmt.html
and here
http://www.cs.uvm.edu/~erickson/education/vb_bmp/BMP.html
 
Top