Manipulating Bitmaps (BMP)

Manipulating Bitmaps (BMP)

Postby codemaker » Wed May 30, 2012 7:56 pm

Is there some library we can use with FWH to manipulate the bitmaps?
I am refering to BMP files

For example, I need the bitmaps we print on some forms to be exactly 150 pixels of height.
The bitmaps we get are of different heights and widths

The idea is to resize each bitmap to be of height 150 pixels and this has to follow the aspect ratio.
So if the initial bitmap was 400 pixels height abd 1000 pixels width, the resulting image would be something like 100 pixels height and 250 pixels width

Another thing is I need to write the changed image to disk under the same name and then actually print it by using oPrn:SayBitmap()

Is there any way to accomplish this using xHb and FWH?

Thanks
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: Manipulating Bitmaps (BMP)

Postby ukoenig » Wed May 30, 2012 8:11 pm

Yes, it is possible.

I will show a sample, how to do it.
Do You want to collect BMP's from different Directorys
and save them resized to a new Directory ?

Best Regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Manipulating Bitmaps (BMP)

Postby codemaker » Wed May 30, 2012 8:53 pm

ukoenig wrote:Yes, it is possible.

I will show a sample, how to do it.
Do You want to collect BMP's from different Directorys
and save them resized to a new Directory ?

Best Regards
Uwe :?:


I want to take the BMP and resize it and save it back under the same name or to some other folder, whatever is easier

Thanks Uwe
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: Manipulating Bitmaps (BMP)

Postby ukoenig » Thu May 31, 2012 8:26 am

Working on a small sample :
Resize to a defined Width, Height or Percent, keeping the Ratio using any Image-format

Image

Best Regards
Uwe :)
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Manipulating Bitmaps (BMP)

Postby codemaker » Thu May 31, 2012 4:11 pm

Thanks Uwe,
I need it :)

BTW: the sample you're preparing can use BMP files also?
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: Manipulating Bitmaps (BMP)

Postby ukoenig » Thu May 31, 2012 5:13 pm

It is finished.

I prefer this Solution, because of very good Quality-results.
All what You need is to include a few Lines of Code.
It is very easy and nothing to calculate.
With just a few Lines much more is possible like Sharpen, Contrast, Brightness, Rotate .....
The Image-previews are showing Alphablended BMP's with a black Background.
I will look for a transparent Solution.

The Download :
http://www.pflegeplus.com/fw_downloads/resize1.zip

The Tool is just for testing Resize-Results ( Quality )

Usage :
1. Copy NCONVERT.exe to Your Appl.-Maindirectory
2. include One of the 3 Sections
( replace Path and Image, You can use a different Output-name if You need )

// Resize given horizontal
cIN_File := D:\P_RESIZE2\DOWNLOAD\IMAGES\PAGE.BMP
cOUT_File := D:\P_RESIZE2\PAGE.BMP
cScript := " -quiet -o " + cOUT_File + " -ratio -resize 50 0 -overwrite " + cIN_File
WAITRUN ( "NConvert " + cScript, 0 )

// Resize given vertical
cIN_File := D:\P_RESIZE2\DOWNLOAD\IMAGES\PAGE.BMP
cOUT_File := D:\P_RESIZE2\PAGE.BMP
cScript := " -quiet -o " + cOUT_File + " -ratio -resize 0 80 -overwrite " + cIN_File
WAITRUN ( "NConvert " + cScript, 0 )

// Resize defined %
cIN_File := D:\P_RESIZE2\DOWNLOAD\IMAGES\PAGE.BMP
cOUT_File := D:\P_RESIZE2\PAGE.BMP
cScript := " -quiet -o " + cOUT_File + " -ratio -resize 150% 0% -overwrite " + cIN_File
WAITRUN ( "NConvert " + cScript, 0 )

Using the Tool :

1. Select a Image
2. define a Destination-Dir
3. Push the Button who belongs to the Resize-mode
4. Select a Resize-mode
5. Use Button Show result
( the used Script is created )


Here is a BMP-test :
A BMP 24x24 resized to 80x80 ( nothing to calculate to keep the Ratio )
3 different Resize-modes are possible : Width, Height and %

Image

Best Regards
Uwe :lol:
Last edited by ukoenig on Fri Jun 01, 2012 11:01 pm, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Manipulating Bitmaps (BMP)

Postby codemaker » Thu May 31, 2012 7:30 pm

Thanks Uwe, I'll give it a try with this external executable.
I hope it will suit my clients needs

If something goes wrong and they cannot use it, is there any chance you can also advise about some function and library to accomplish the same task directly from PRG ?

Thanks a lot Uwe
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: Manipulating Bitmaps (BMP)

Postby codemaker » Fri Jun 01, 2012 1:45 pm

Uwe,
Unfortunately my client is not happy to install any additional EXE on his computer, so the option you showed me is not what he wants... :(

Is there some library I can use to do simillar thing directly from xHB+FWH program? Or maybe some ActiveX?

Thank you for your help
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: Manipulating Bitmaps (BMP)

Postby Gale FORd » Fri Jun 01, 2012 1:51 pm

With ActiveX you would have to install it to the computer.
With nconvert you do not need to install anything. You just copy it to the same directory. It is a lot easier than installing and maintaining an ActiveX control.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Manipulating Bitmaps (BMP)

Postby ukoenig » Fri Jun 01, 2012 2:22 pm

I agree with Gale,

there is nothing to install, like You have to do working with a activeX.
That makes the usage very easy.
Maybe it is a bit confusing, because of a EXE.
The basic-functions are comming from Image-MAGICK.

New Release of NCONVERT
http://www.xnview.com/en/download_nc.html

ImageMAGICK
http://www.imagemagick.org/script/index.php

NCONVERT is just a compiled Versions will all these functions.
It is also possible, to use MAGICK-functions directly, but it is more complicated.
The difference : MAGICK You have to install.

Read about ImageMAGICK :

ImageMagick® is a software suite to create, edit, compose, or convert bitmap images.
It can read and write images in a variety of formats (over 100)
including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF.
Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images,
adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses
and Bézier curves.
The functionality of ImageMagick is typically utilized from the command line or you can use
the features from programs written in your favorite language.
Choose from these interfaces: G2F (Ada), MagickCore (C), MagickWand (C),
ChMagick (Ch), ImageMagickObject (COM+), Magick++ (C++), JMagick (Java), L-Magick (Lisp),
NMagick (Neko/haXe), MagickNet (.NET), PascalMagick (Pascal), PerlMagick (Perl),
MagickWand for PHP (PHP), IMagick (PHP), PythonMagick (Python), RMagick (Ruby),
or TclMagick (Tcl/TK).
With a language interface, use ImageMagick to modify or create images dynamically
and automagically.

ImageMagick is free software delivered as a ready-to-run binary distribution or as source code
that you may freely use, copy, modify, and distribute in both open and proprietary applications.
It is distributed under the Apache 2.0 license, approved by the OSI and recommended
for use by the OSSCC.

The ImageMagick development process ensures a stable API and ABI. Before each ImageMagick
release, we perform a comprehensive security assessment that includes memory and thread
error detection to prevent security vulnerabilities.

The current release is ImageMagick 6.7.7-5.


Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Manipulating Bitmaps (BMP)

Postby codemaker » Fri Jun 01, 2012 3:02 pm

I also agree with you Uwe and with Gale....

But as you both know, there are clients which are so paranoic, when they see any EXE not being there before, they start screaming. Not only that, after then if anything works wrong on their computer, they blame our "new" executable immediately.... :(

I am also aware that the ActiveX must have installed component, so practically I am on square one again...

I am willing to buy some library which can we use in program to do the required task.
Does anyone of you knows such library which can be used xHB+FWH combination?
This way I will not have problem with client if they suddenly cannot watch Youtube clips :)

Thank you both
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: Manipulating Bitmaps (BMP)

Postby Enrico Maria Giordano » Fri Jun 01, 2012 10:03 pm

codemaker wrote:But as you both know, there are clients which are so paranoic, when they see any EXE not being there before, they start screaming.


Just rename it as DLL. You can use it just like it were an EXE and your clients will be quiet. Or do they scream for a new DLL too? :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Manipulating Bitmaps (BMP)

Postby ukoenig » Fri Jun 01, 2012 11:05 pm

Enrico,

Thank You very much for the Info.
It seems, WAITRUN doesn't need the real Filextension ?

Old :
WAITRUN ( "NConvert " + cScript, 0 )

New changed to :
WAITRUN ( "NConvert.dll " + cScript, 0 )

Best Regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Manipulating Bitmaps (BMP)

Postby codemaker » Sat Jun 02, 2012 7:35 am

Enrico Maria Giordano wrote:
codemaker wrote:But as you both know, there are clients which are so paranoic, when they see any EXE not being there before, they start screaming.


Just rename it as DLL. You can use it just like it were an EXE and your clients will be quiet. Or do they scream for a new DLL too? :-)

EMG

Hm, that's an interesting idea...
As Uwe asked, can we use this "dll" with WAITRUN()?

If I rename any of my EXE programs to DLL, it will not run, the system asks me to answer how to open it.... Maybe Waitrun() can run it
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: Manipulating Bitmaps (BMP)

Postby ukoenig » Sat Jun 02, 2012 8:57 am

I noticed Winexec works the same.
( never tested before )
That means, You could protect a Program, to be executed from outside.
Waitrun can start a renamed Exe as a Background-process.

I renamed < Copy1.exe > to < Copy.abc > and called it from < Copy2.exe >
Image

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 83 guests