ImageLibEx library

Discussion in 'Additional Libraries' started by agraham, Oct 20, 2008.

  1. agraham

    agraham Expert Licensed 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.
     

    Attached Files:

    Last edited: Jul 20, 2010
  2. Erel

    Erel Administrator Staff Member Licensed 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
     
  3. klaus

    klaus Expert Licensed 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: Jan 6, 2009
  4. agraham

    agraham Expert Licensed User

    Thanks, I've corrected them ready for the next version.
     
  5. derez

    derez Expert Licensed 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
     
  6. agraham

    agraham Expert Licensed User

    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.
    Code:
    Points() = Array ( (10120), (200120), (200200), (10200))
       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: Oct 23, 2008
  7. derez

    derez Expert Licensed 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
     
  8. agraham

    agraham Expert Licensed User

    Why not?
    Code:
    Dim routepoints(0,0' in Globals
    ...
    ...
    Dim routepoints (b-a+22)
    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())
    ...
     
  9. derez

    derez Expert Licensed User

    I get this
     

    Attached Files:

  10. agraham

    agraham Expert Licensed 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.
    Code:
    Dim routepoints(0,0As Int32 ' in Globals
    ...
    ...
    Dim routepoints (b-a+22As 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())
    ...
     
  11. agraham

    agraham Expert Licensed User

    Looking closely at that error you have a typo. You are missing the drawlines method after "drawer."
     
  12. derez

    derez Expert Licensed 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: Oct 23, 2008
  13. klaus

    klaus Expert Licensed 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.
     
  14. agraham

    agraham Expert Licensed User

    Thanks Klaus, I've amended the help for the next version accordingly. That was quite a big help file to put together and proof read so I wouldn't be surprised if there are other cut and paste type errors waiting for someone to notice them.
     
  15. klaus

    klaus Expert Licensed 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.
     
  16. agraham

    agraham Expert Licensed User

    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.
     
  17. klaus

    klaus Expert Licensed 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.
     

    Attached Files:

    Last edited: Nov 15, 2008
  18. agraham

    agraham Expert Licensed User

    Yes I did thanks, I've amended the help file for any future release.

    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.
     
  19. klaus

    klaus Expert Licensed User

    Thank you Andrew, I will have a look at it. It's for a desktop only program.

    Best regards.
     
  20. Byak@

    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?
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice