Found 34489 Articles for Programming

Check if the File object refers to an absolute pathname in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24

312 Views

The method java.io.File.isAbsolute() is used to check if the file object refers to an absolute pathname. This method returns true if the abstract path name is absolute and false if the abstract path name is not absolute.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo {    public static void main(String[] args) {       File file = new File("C:" + File.separator + "jdk11.0.2" + File.separator, "demo1.java");       System.out.println(file.isAbsolute());    } }The output of the above program is as follows −OutputfalseNow let us understand the above program.The isAbsolute() method is used ... Read More

Get the name of the file and path in Java

Samual Sam
Updated on 30-Jul-2019 22:30:24

6K+ Views

The name of the file and the name of the path can be obtained using the methods java.io.File.getName() and java.io.File.getPath() respectively. The getName() returns the name of the file or the directory. The getPath() returns the abstract pathname in the form of a pathname string.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo {    public static void main(String[] args) {       File file = new File("C:" + File.separator + "jdk11.0.2" + File.separator, "demo1.java");       System.out.println("File name: " + file.getName());       System.out.println("Path name: " + file.getPath());    } ... Read More

imagecreatetruecolor() function in PHP

Arjun Thakur
Updated on 31-Dec-2019 08:05:48

703 Views

The imagecreatetruecolor() function creates a new true color image.Syntaximagecreatetruecolor (width , height )Parameterswidth: The image width.height: The image height.ReturnThe imagecreatetruecolor() function returns an image resource identifier on success, FALSE on errors.ExampleThe following is an example Live DemoOutputThe following is the output displaying the height and width of the new image:500 600ExampleLet us see another example with different height and width: Live DemoOutputThe following is the output displaying the height and width of the new image:450 300

imageconvolution() function in PHP

Chandu yadav
Updated on 31-Dec-2019 08:00:58

84 Views

The imageconvolution() functionSyntaxbool imageconvolution (img, matrix, div, offset )Parametersimg: Create image with imagecreatetruecolor() function.matrix: A 3x3 matrix is an array of three arrays of three floats.div: Divisor of the result of the convolution, used for normalization.offset: The color offset.ReturnThe imageconvolution() function returns True on success or False on failure.ExampleThe following is an exampleOutputThe following is the outputExampleLet us see another example with different parameter values for the same image. You can easily spot the difference now:OutputThe following is the output

imagecolormatch() function in PHP

Ankith Reddy
Updated on 31-Dec-2019 07:59:35

43 Views

The imagecolormatch() function forms the colors of the palette version of an image more closely match the true color versionSyntaxbool imagecolormatch ( img1, img2 )Parametersimg1: Create image with imagecreatetruecolor() function.img2: A palette image link resource pointing to an image. This image has the same size as img1.ReturnThe imagecolormatch() function returns TRUE on success or FALSE on failure.ExampleThe following is an example Live DemoOutputThe following is the output:1ExampleLet us see another example Live DemoOutputThe following is the output:1

imagecolortransparent() function in PHP

George John
Updated on 31-Dec-2019 07:58:19

272 Views

The imagecolortransparent() function is used to set the color of a transparent image.Syntaximagecolortransparent ( img, color )Parametersimg: Create image with imagecreatetruecolor() function.color: Color identifier created with imagecolorallocate().ReturnThe imagecolortransparent() function returns the identifier of the new transparent color. The return value is -1 if color is not specified and the image has no transparent color.ExampleThe following is an exampleOutputThe following is the output:

imagecolorresolve() function in PHP

Arjun Thakur
Updated on 31-Dec-2019 07:48:35

19 Views

The imagecolorresolve() function gets the index of the specified color or its closest possible alternative.Syntaximagecolorresolve (img , red , green , blue )Parametersimg: Image created with imagecreatetruecolor() function.red: The value of red component.green: The value of green component.blue: The value of blue component.ReturnThe imagecolorresolve() function returns the color index.ExampleThe following is an example Live DemoOutputThe following is the output:Array ( [0] => 128 [1] => 129 [2] => 130 )

imagecolorstotal() function in PHP

Chandu yadav
Updated on 31-Dec-2019 07:47:13

38 Views

The imagecolorstotal() function gets the count of colors in an image's paletteSyntaximagecolorstotal (img)Parametersimg: Image created with imagecreatetruecolor().ReturnThe imagecolorstotal() function returns the number of colors in an image palette.ExampleThe following is an example Live DemoOutputThe following is the output:Number of Colors = 128

imagecolorset() function in PHP

Ankith Reddy
Updated on 31-Dec-2019 07:46:41

77 Views

The imagecolorset() function sets the color for the specified palette index. Using this create flood-fill-like effects in palleted images.Syntaximagecolorset ( img, index, red, green, blue, alpha )Parametersimg: Image created with imagecreatetruecolor() functionindex: The index in the palette imagered: Value of red componentgreen: Value of green componentblue: Value of blue componentalpha: The transparency if image.ReturnThe imagecolorset() function returns nothing.ExampleThe following is an exampleOutputThe following is the output:

imagecolorsforindex() function in PHP

George John
Updated on 31-Dec-2019 07:46:17

56 Views

The imagecolorsforindex() function gets the colors for an index.Syntaximagecolorsforindex ( img, index )Parametersimg: Creates an image with imagecreatetruecolor()Index: Set the color index.ReturnThe imagecolorsforindex() function returns an associative array with red, green, blue and alpha keys that contain the appropriate values for the specified color index.ExampleThe following is an example Live DemoOutputThe following is the output:array(4) { ["red"]=> int(255) ["green"]=> int(255) ["blue"]=> int(255) ["alpha"]=> int(127) }

Advertisements