ImageLibEx library

agraham

Expert
Licensed User
Longtime User
This library is a replacement for ImageLib upon which it was modelled using the ImageLib source (with Erels prior agreement) as a start - it's a bit different now :)

Check out the demo, particularly on the desktop, to see what can now be done. Two libraries, for desktop and device, source for merging, help and a demo are in the zip. Both desktop and device require .NET 2.0.

EDIT :- Version 1.1 posted with new method BitmapEx.Rotate which rotates a bitmap an arbitrary number of degrees. Note that if you want to merge the source for a device app you need to put a SIP(False) statement in your App_Start if you do not already use SIP elsewhere. This forces the Basic4ppc to reference a .NET assembly that it would not otherwise do and that is required for merging. This need will be removed with the next version of Basic4ppc.

EDIT :- Version 1.2 posted with improvements. See post #31 for details.

EDIT :- Version 1.3 posted with bitmap alpha blending. See post #50 for details.

EDIT :- Version 1.4 posted with minor tweak to BitmapEx.Zoom memory management and BitmapEx.Zoom documented in the help. There is (at least) one error in the help. See post #67.

EDIT :- Version 1.5 posted. See post #85 for details.

EDIT :- Version 1.6 posted. See post #103 for details.

EDIT :- Version 1.7 posted. See post #105 for details.

EDIT :- Version 1.8 posted. See post #106 for details.

EDIT :- Version 1.9 posted. See post #115 for details.

EDIT :- Version 2.0 posted. See post #136 for details.

EDIT :- Version 2.1 posted. See post #142 for details.

EDIT :- Version 2.2 posted. See post #177 for details.
 

Attachments

  • ImageLibEx2.2.zip
    234.9 KB · Views: 504
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Looks great!
Small tip for new users:
The simplest way to install it is to copy the following files to Basic4ppc libraries folder:
ImageLibExDevice.dll (device library)
ImageLibExDesktop.dll (desktop library)
ImageLibExDevice.cs (required for merging)
ImageLibExDesktop.cs (required for merging)
ImageLibEx.chm (help file)

The libraries folder is usually located under:
C:\Program Files\Anywhere Software\Basic4ppc Desktop\Libraries
 

klaus

Expert
Licensed User
Longtime User
Hi Andrew,

I just discovered your new ImageLibEx, it is pretty good news. I have not yet 'played' with it, but will do it quite soon. It combines the functionalities of the form's drawing functions and the ImageLib ones and adds new welcomed functions in ONE library. That's great !

I found two typos in the help file.
- In the list of objects in the left list Rectangle should be RectangleEx
- In the drawer, the function
RefreshForm2 (form As Form, x As Int32, y As Int32, width As Int32, height As Int32)
should be
RefreshForm2 (form As Form, rect As Rectangle)

Best regards and congratulations for this great job.
 
Last edited:

derez

Expert
Licensed User
Longtime User
Agraham
Thanks for this library :sign0060:

I'm trying to use the drawlines and do not understand it, can you please check that the definition is correct :
in the help file:
DrawLines (pen As Pen, x1 As Int32, xy(n,2))

in the context menu its without the x1

anyway, I have two dimensional array name routepoints, I want to draw connected line from point 2 to 7 , how should i write it ? (the points are already defined in the array)

DrawLines (pen.value, routepoints??????) ?

Thanks
 

agraham

Expert
Licensed User
Longtime User
in the help file:
DrawLines (pen As Pen, x1 As Int32, xy(n,2))
Sorry, that's a cut and paste error in the help, the x1 shouldn't be there. Look at lines 126 & 127 in the Main.DrawLine Sub for an example.
B4X:
   Points() = Array ( (10, 120), (200, 120), (200, 200), (10, 200))
   BackDrawerEx.DrawLines(PenEx.Value, Points())

EDIT :- I may not have understood your question correctly. DrawLines connects all the points in the array by drawing lines between them in sequence. Draw Polygon is the same except it also joins the first and last point together to close the polygon. To draw from point 2 diectly to point 7 do something like

DrawLine(PenEx.Value, points(2,0), point(2,1), points(7,0), point7,1))
 
Last edited:

derez

Expert
Licensed User
Longtime User
OK, I see the problem now.

I can start it from the first point but I don't know how many points I have, and I can assign the value only inside a loop, not as an array declaration.

I don't thing that array list can accept two dimensions ...

The code goes like this:

...
For i = a To b + 1
Point(i).x = (...some calculation)
routepoints(i-a,0) = Point(i).x ' so it starts from 0
Point(i).y = (...some calculation)
routepoints(i-a,1) = Point(i).y
Next

drawer.(pen.Value, routePoints())

...

In polygon Erel used two arraylists to define the coordinates:
AddArraylist("alX")
AddArraylist("alY")

any suggestion ?

Thanks
 

agraham

Expert
Licensed User
Longtime User
Why not?
B4X:
Dim routepoints(0,0) ' in Globals
...
...
Dim routepoints (b-a+2, 2)
For i = a To b + 1 
  Point(i).x = (...some calculation)
  routepoints(i-a,0) = Point(i).x ' so it starts from 0
  Point(i).y = (...some calculation)
  routepoints(i-a,1) = Point(i).y
Next
drawer.(pen.Value, routePoints())
...
 

agraham

Expert
Licensed User
Longtime User
Ooops! The array should be Int32. I don't know why it not being Int32 might cause that error, I would expect a type error. If it persists post the bit of code that causes it.
B4X:
Dim routepoints(0,0) As Int32 ' in Globals
...
...
Dim routepoints (b-a+2, 2) As Int32
For i = a To b + 1 
  Point(i).x = (...some calculation)
  routepoints(i-a,0) = Point(i).x ' so it starts from 0
  Point(i).y = (...some calculation)
  routepoints(i-a,1) = Point(i).y
Next
drawer.(pen.Value, routePoints())
...
 

derez

Expert
Licensed User
Longtime User
Checking slowly - I found it in this line:

drawer.(pen.Value, routePoints())

which should be:

drawer.drawlines(pen.Value, routePoints())


:signOops:


Thanks :)

And everything works fine now !
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Hi Andrew,

I am beginning to use your ImageExLib.

I found some typos for the DrawerEx object:
StringHeight (string As String, FontSize As Single)
StringWidth(string As String, FontSize As Single)

should be
StringHeight (string As String)
StringWidth(string As String)

If the need to declare the points array as Int32 remains in the future, it would be interesting to have a mention on it in the help file.
Dim Points(n,2) as Int32

Best regards.
 

klaus

Expert
Licensed User
Longtime User
Hi Andrew,

In using the ImageExLib I found another typo in the help file.

in the help file this line
DrawImage1 (image As Image, rectSrc As Rectangle, rectDest As Rectangle, transparent As Boolean)

the program wants this:
DrawImage (image As Image, rectSrc As Rectangle, rectDest As Rectangle, transparent As Boolean)

In the ImageLib it is DrawImag1 which one do you want to use ?

Best regards.
 

agraham

Expert
Licensed User
Longtime User
In the ImageLib it is DrawImag1 which one do you want to use ?
I named it DrawImage deliberately seeing as there is only a single method of that name. I suspect that in the past ImageLib was intended/had a second DrawImage method but actually only ended up with one.
 

klaus

Expert
Licensed User
Longtime User
I am not sure if you noticed that in the help file of the ImageExLib the text is DrawImage1 but should therefore be DrawImage .
I send this once more to make it sure.

Another question, I am almost sure that it is not the case but ask it even so. Can the dimensions od the dashes and or dots in the lines be changed for a given linewidth? They change with the linewidth, because with a width of 1 pixel oblique lines don't look that nice.

Joined 2 screenshots with widths of 1,2 and 3.

Best regards.
 

Attachments

  • Lines_1.jpg
    Lines_1.jpg
    22.6 KB · Views: 43
  • Lines_2.jpg
    Lines_2.jpg
    26.2 KB · Views: 36
  • Lines_3.jpg
    Lines_3.jpg
    27.5 KB · Views: 38
Last edited:

agraham

Expert
Licensed User
Longtime User
I send this once more to make it sure.
Yes I did thanks, I've amended the help file for any future release.

Can the dimensions od the dashes and or dots in the lines be changed for a given linewidth?
On the desktop only yes, by a Pen property, DashPattern, that could probably be set by the Door library.

Drawing on the device is somewhat different to the desktop. That is why there are different way of rotating fonts on desktop and device. I tried to make the desktop and device libraries reasonably compatible so that what drew on the desktop would more or less draw on the device.

I was going to look at an "ImageLibPlus" for the desktop that took advantage of the far superior graphics on the desktop but I haven't done anything yet as I got sidetracked by GPS software.
 

Byak@

Active Member
Licensed User
Hello agraham!it's very-veru good lib but i not find one metod...this metod i'm find in all libs but nothihg...
How can i rotate image for some degrees?for example 37 degrees?
 
Top