ImageLibEx library

agraham

Expert
Licensed User
Longtime User
Coredll.dll is the main device native code library. There is not a desktop version of it. The advanced drawing functions are implemented entirely differently on the desktop to the device, that is why there are two ImageLibEx libraries. The device needs to call native code for some things that are available in the .NET Framework on the desktsop. To implement gradient fill you will also need two different libraries or possibly one with conditional statements to do the right thing at runtime.
 

moster67

Expert
Licensed User
Longtime User
Thank you!

Where do you find the time (and the inspiration)? Any secrets you may share with us "normal human beings" to benefit from? :)

Version 2.1 now posted includes support for individual pixel alpha values so you can now blend images with alpha values, such as PNGs, and get proper transparency. See the "Alpha blending overview" in the gelp.
 

Merlot2309

Active Member
Licensed User
Longtime User
Andrew,

Just used this lib for the first time and I can't tell you enough how happy I am with the pieces of art that you create.

A huge THANK YOU!!

Regards,
Helen.
 

chanppc

Member
Licensed User
Thank you for the latest library which helped me to solve the png alphabend issue. Hopefully you can give me some pointer how I can do the below:

I've 2 images to be blend together. The 1st one is a normal jpg (base image), and the 2nd one is a smaller png with transparent image.

I can blend them together using the AlphaPixelBlend. My question: is there a better way I can resize & crop part of the png before merging it to the jpg?


My current code seems to be a bit lengthy:
1. Resize the jpg to smaller (losing info) using drawerEx.DrawImage
2. AlphaPixelBlend the 2 images
3. resize it for display
 
Last edited:

agraham

Expert
Licensed User
Longtime User
The alpha bitmap has a width of mainimage.width/3 +1 and a height of mainimage.height. Using DrawImage you should be able to crop the main image starting at an x that is a multiple of three and crop the alpha bitmap to match starting at x/3 with a length of newmainwidth/3 + 1. As the vertical resolutions are the same use the same y start and height for both.

I don't think resizing will work without giving you some edge effects but you could try and see what it looks like.
 

seongjin

Member
Licensed User
Longtime User
I thought a cirlce will be located at the very center, but result is different. it's moved to right-bottom a little bit.
What is wrong on my script?

Advise me, please...

'cvs: BitmapEx, drw: DrawerEx, pen: PenEx
frmMain.Show
cvs.New2(frmMain.Width, frmMain.Height)
xCtr = cvs.Width/2
yCtr = cvs.Height/2
pen.New1(cBlue)
drw.New2(cvs.Value)

drw.DrawCircle(pen.Value, xCtr, yCtr, 133)

frmMain.DrawImage(cvs.Value,0,0)
 

seongjin

Member
Licensed User
Longtime User
Really appreciate for the great library...

It would be nice when support GradientFill for Circle... It will be helpful for bullet/button design on bList.

gradation.png
 

agraham

Expert
Licensed User
Longtime User
If you are looking at it on the desktop it is because Basic4ppc doesn't get the desktop client area the correct size. This is a long-standing bug that (I hope) Erel will fix with the next release.

Gradient fill for circle is a nice idea but I'm afraid it is not supported on the device. It is possible on the desktop so I might look at putting it in my GDI+Desktop library.
 
Last edited:

seongjin

Member
Licensed User
Longtime User
Gradient fill for circle is a nice idea but I'm afraid it is not supported on the device. It is possible on the desktop so I might look at putting it in my GDI+Desktop library.

I see. It's a known bug.....

I simulated it by changing radius and Fill color of the circle consecutively and it worked on device...

B4X:
   iRad = 20
   fct1 = Ln(iRad)/255
   For i=iRad To 1 Step -1
      '1.7 to 0
      cR1 = Int(Ln(i)/fct1)
      cR2 = 255-Int(Ln(iRad+1-i)/fct1)
      'Msgbox("Calculated Log(" & i & ") = " & cR1 & CRLF & cR2)
      brs.Color = Rgb(cR1,0,0)
      drw.FillCircle(brs.Value, xCtr-50, yCtr-50, i)
      brs.Color = Rgb(cR2,0,0)
      drw.FillCircle(brs.Value, xCtr+50, yCtr-50, i)
   Next

Would be nice to have feature.

Thanks again for the kindness.
 

derez

Expert
Licensed User
Longtime User
The attached modified library will draw a gradient circle on desktop and device.

Make a penEx and DrawerEx objects.

B4X:
Sub App_Start
   Form1.Show
   pen.New1(cBlack)
   dr.New1("form1",False)
   dr.GradientCircle(100,100,50,cYellow,cBlue)
   dr.drawCircle(pen.Value,100,100,50)
End Sub
 
Last edited:

agraham

Expert
Licensed User
Longtime User
If you are going to take my source codes, change them, recompile them and then publish them you might at least have the courtesy to change the names to avoid confusion and to also publish the amended source as well! :(

There are certain conventions usually observed when making use of other peoples intellectual property.
 

derez

Expert
Licensed User
Longtime User
Agraham
Never meant to steal your property or to try to make it look as if I made it.
As I have only recently started to work with libraries, I can only dream on writing such a library.
I thought I made it clear that it is not my library by adding a post here (not as a new thread) and with this
The attached modified library

I'm sorry that it looked foul to you.:sign0013:

I didn't add the source because I didn't want it to replace your library, just to help seongjin.

Here is the piece of code I added, you can use it or not - as you wish.

B4X:
public void GradientCircle(  int x, int y, int radius, int startcolor, int endcolor)
        {
              System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(Color.FromArgb(endcolor));
            Color sc = Color.FromArgb(startcolor);
            Color ec = Color.FromArgb(endcolor);
            int rc = (sc.R - ec.R)/radius;
            int gc = (sc.G - ec.G)/radius;
            int bc = (sc.B - ec.B)/radius;
         
              for (int i=radius;i>0;i--)
           {
            System.Drawing.Rectangle rect = new System.Drawing.Rectangle(x - i, y - i, i * 2, i * 2);
            brush.Color =  Color.FromArgb( ec.R + rc*i, ec.G + gc*i , ec.B + bc*i);
            g.FillEllipse(brush, rect);
           }
        }
 
Last edited:

ceaser

Active Member
Licensed User
Hi Agraham:sign0188:

I am rewriting my CAD module using your library. Is it possible to add different line types to the rectangles as well please. When one draws a box on the screen to select drawing entities, then it would be nice to have this box as dashed lines.

Regards
Michael
 

ceaser

Active Member
Licensed User
Hi Agraham

Something else. Is it please possible to introduce another "Rectangle" method by defining the two opposite corners of the rectangle?

The reason why I ask this, is because the user of the CAD program can define a rectangle using the stylus from left to right, right to left, from top to bottom, bottom to top, etc.

Thanks for a great library:sign0060:

Regards
Michael
 

agraham

Expert
Licensed User
Longtime User
In the Compact framework there is no intrinsic way of drawing a rectangle by specifying its' co-ordinates. Rather than synthesising it within the library I would suggest that you make your own version in a module.

You should be able to draw a dashed rectangle on the device using a PenEx with DashStyles set to 1. The Compact Framework only supports a single dash style so if you want something different I again suggest that you roll your own using using DrawLineDashed or DrawLineDashDot.
 

klaus

Expert
Licensed User
Longtime User
Hi Michael,

I have used this workaround:
B4X:
[FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]x0=[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Min[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2](x1,x2)[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]y0=[/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Min[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2](y1,y2)[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]w=[/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Abs[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2](x2-x1)[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]h=[/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Abs[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2](y2-y1)[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]drwMain.DrawRectangle2(pen1.Value,x0,y0,w,h)[/FONT][/SIZE][/SIZE][/FONT]
x1,y1 and x2,y2 are the coordinates of the 2 corner points of the rectangle.

Best regards.
 
Top