ImageLibEx library

agraham

Expert
Licensed User
Longtime User
From the help file for the Font object (same as NormalFont in the ImageLibEx) in the new GDI+Desktop library
Value : Font [I/)] : Gets or sets a Font object that can be used by DrawerEx to render text. Note that assigning a Font object to this property does not copy a reference to the font but only copies its attributes such as size etc. Getting a Font object from this property always results in a reference to a new instance of a font. The reason for this is that fonts are immutable once created so if the attributes are changed a new instance of a font must be created.
 

agraham

Expert
Licensed User
Longtime User
I should read more often the help files.
It wouldn't have helped unless you were very quick off the mark - I only posted GDI+Desktop about an hour ago, that detail wasn't in the ImageLibEx help. Checkout the printing support in GDI+Desktop, it might mean that you can do some nice printing from your design apps on the desktop.
 

agraham

Expert
Licensed User
Longtime User
Version 1.4 now posted with a very minor tweak to BitmapEx.Zoom memory management to dispose of an internal Bitmap object rather than rely upon the .NET garbage collector.

BitmapEx.Zoom is now documented in the help. It existed previously but I missed including it in the help.
 
Last edited:

marathon332

Member
Licensed User
Longtime User
Great library...

Can't seem to get the bitmap to save... can you post some examples?

Thanks...
--Steve
 

agraham

Expert
Licensed User
Longtime User
:signOops: The help is wrong, it was copied from my ImageEdit library and should have been edited but I overlooked it. :sign0013:

SaveImage(PathName As String, Format As String) : Saves a file to to the PathName specified in the Format specified. Note that a file extension is not added and must be specified as part of the PathName. The file formats are"J" for jpg : "B" for bmp : "G" for gif : "P" for png. Anything else is saved as jpg. Desktops should support all formats, devices may only support "J".

BitmapEx.SaveImage(AppPath & "\test.jpg","J")
 

marathon332

Member
Licensed User
Longtime User
Thanks... I got it working.

Is there any way that transparency could be set for saving of png's and gifs?

Thanks again for your help..

--Steve
 

Byak@

Active Member
Licensed User
Hello Agraham!i have a big problem...
in my program i'm use your formex desctop lib.
i must draw same images in some coordinates.with standart metods of formex i can't do it.
maybe it real with imagelibex?
i try but could not.i have some errors!
please help me
 

Byak@

Active Member
Licensed User
it is example.i must draw image at 30,50 forexample.how?
 

Attachments

  • FormExDesktop.zip
    8 KB · Views: 20

agraham

Expert
Licensed User
Longtime User
it is example.i must draw image at 30,50 forexample.how?
If you look in the help for FormEx.DrawImage you will see that it takes no parameters and sets the Background image of the FormEx. You can't therefore offset an image from the form origin. A FormEx will maintain its background image without needing to have it repainted in the Paint event whereas the other b... drawing methods are volatile.

DrawImage(Path AS String) : Sets the background image of the form. Images are treated slightly differently to a Basic4ppc form. An ImageLayout property (see below) governs how the image is displayed on the form.

I guess I should also have implemented a bDrawImage that would have done what you wanted but would be volatile but I didn't!
 

Byak@

Active Member
Licensed User
you dont understanr me...i mast place image on form in coordinates
for example in 30,50 (x,y)
in standart form i can do it with drawimage(image,X,Y).
on formex a may only draw backgraund image...maybe i can draw image in coordinats with imagelibex?in my example i can't do it...why?
 

agraham

Expert
Licensed User
Longtime User
Like this?

B4X:
Sub Globals
   'Declare the global variables here.

End Sub

Sub App_Start
mainfex.New1("main.mainf")
mainfex.Run
End Sub

Sub mainfex_showing
mainfex.Text="shown"
bmp1.New1(AppPath&"\garden.jpg")
bmp2.New2(mainfex.Width, mainfex.Height)
mainfex.ImageLayout = 0
mainfex.Image = bmp2.Value
drawex.New2(mainfex.Image)
rect1.New1(0,0,bmp1.Width, bmp1.Height)
rect2.New1(20,30,bmp1.Width, bmp1.Height)
drawex.DrawImage(bmp1.value,rect1.Value,rect2.Value,False)
End Sub
 

Byak@

Active Member
Licensed User
Yes Yes Yes!!!big thanks!!
 

tsteward

Well-Known Member
Licensed User
Longtime User
I love your library's thanks for all your work.

Now will bmpImage.SaveImage overwrite an existing image?

I am unable to do so and am wondering if its me or a lib limitation.
I have tried to delete the file before saving but get a file is in use error.
 

agraham

Expert
Licensed User
Longtime User
Now will bmpImage.SaveImage overwrite an existing image?
No-ish! While a Bitmap loaded from a file exists the file is locked and cannot be deleted or overwritten see post #7 here http://www.b4x.com/forum/questions-help-needed/3317-image-locking.html#post18740

There is also a bug in the current version of Basic4ppc. If you want to use New on an existing Bitmap or BitmapEx then you should use Dispose on it first. See posts #16 ands #22 here http://www.b4x.com/forum/questions-help-needed/3655-image-zoom-memory-problem-2.html#post20956
 

klaus

Expert
Licensed User
Longtime User
Hi Andrew,

I have some wishes for additional functions:
- a Circle function, like for the form DrawCircle(pen,x,y,radius)
- a FillCircle function FillCircle(brush,x,y,radius)
and why not DrawArc and FillArc functions ?
so we would have almost all possible drawing functions in one Object.

If the FillArc wouldn't be implemented,
- a second FloodFill function, the current one replaces the pixel at the given coordinates with a given color and all adjacent pixels with the same color by a new given color.
The function I would like to have is: replace the pixel at the given coordinate by the new color and all adjacent pixels until reaching a given color.
Example: in the Draw program I added arc drawing functions and I would like to get a filled sector, by replacing the pixels inside the sector with their background image colors by the fill color.
I know that I could do it with the FillPolygon function, having the center, the begin and end points of the arc and calculate a certain number of points on the arc.

Thank you in advance and best regards.
 

agraham

Expert
Licensed User
Longtime User
I have some wishes for additional functions:
- a Circle function, like for the form DrawCircle(pen,x,y,radius)
- a FillCircle function FillCircle(brush,x,y,radius)
What's wrong with

Rect1.New1(x-radius, y-radius, radius*2, radius*2)
DrawEllipse(Pen1.Value, Rect1.Value)

Rect1.New1(x-radius, y-radius, radius*2, radius*2)
FillEllipse(Brush1.Value, Rect1.Value)

That's what I would have to do in the library.
and why not DrawArc and FillArc functions ?
Because GDI on the Compact Framework doesn't include this and I deliberately restricted ImageLibExDesktop to what was (more or less) also available on the device. DrawArc and DrawPie are included in my GDI+Desktop library which exposes the more advanced stuff on the desktop.

- a second FloodFill function,
Looks fairly easy on first glance, I'll take a proper look in a day or so. I'm tied up at the moment.
 
Top