I have to set a image on wizard dialogue,classpath load this image, but image not displayed properly - eclipse-plugin

I have to set a image on wizard dialogue in swt,classpath load this image but image not displayed properly. In my design create a composit in this composit create a lebel.there after in this lebel I want add an image.After that i will create a runnable jar.This jar will be executed with proper image. In my implementation part i have create a resources (src folder) within src folder and in this resources folder kept image which i need.Please find the below code,
File file = new File("resources/Automatics_Logo.png");
Image image = new Image(Display.getDefault(), file.getPath());
Label lblNewLabel_4 = new Label(composite, SWT.NONE);
lblNewLabel_4.setImage(SWTResourceManager.getImage(CheckSystemConfigurationAndInstallation.class,image.toString()));

Image imgSWT=null; // Image class is the SWT Image class
ImageDescriptor imgDesc=null;
java.net.URL imgURL = IntroductionPage.class.getResource("/Automatics_Logo.png");
if (imgURL != null) {
imgDesc = ImageDescriptor.createFromURL(imgURL);
imgSWT = imgDesc.createImage();

Related

How to set background image to shell or composite in SWT

public class createShell{
System.out.println("Inside shell create");
display = new Display();
shell = new Shell(display);
shell.setSize(990, 590);
shell.setLayout(new GridLayout());
Composite comp = new Composite(shell, SWT.NO_FOCUS);
comp.setBounds(10, 10, 720, 400);
}
I have existing code like this. Need to set a background image to shell. How to give relative path of image.
The folder structure of plug-in(com.vcc.rac.ks5lmpp) is as per image.path The code file is in package inside src folder(plugins\com.rac.ks5lmpp\src\com\kjj\rac\ks5lmpp\stylesheets\dialogs\createShell.java)
There exists a image folder(plugins\com.rac.ks5lmpp\src\com\kjj\rac\ks5lmpp\stylesheets\dialogs\images) in which the image is there which I want to pass as background.
Image size is of 676X324 of PNG type.
Thanks in advance.
You use FileLocator in an Eclipse plug-in to find resources in the plug-in.
Bundle bundle = FrameworkUtil.getBundle(getClass()); // Or some other way to find the current bundle
URL url = FileLocator.find(bundle, new Path("path within the plugin"));
ImageDescriptor desc = ImageDescriptor.createFromURL(url);
Image image = desc.createImage();
shell.setBackgroundImage(image);
Note: You should arrange to dispose of the image when the shell closes.
Be sure that the build.properties for the plug-in includes the images.
FileLocator is org.eclipse.core.runtime.FileLocator.
Path is org.eclipse.core.runtime.Path (not the java.nio.file Path)
ImageDescriptor is org.eclipse.jface.resource.ImageDescriptor

Embed pdf content in pdf layer

I just registered. I try to address the following case:
Given a basic pdf (a simple, single raster image), I want to get to:
Create a pdf (empty initially), in which I create a layer, in which I embed the raster image of the input_pdf, and mark said layer as visible and not_printable.
Are there tools to do it?
Thanks for the tips.
Since you do not specify a language or a library you use, here it is a solution in C#:
// Extract the page content from the source file.
FileStream stream = File.OpenRead("input.pdf");
PDFFile source = new PDFFile(stream);
PDFPageContent pageContent = source.ExtractPageContent(0);
stream.Close();
PDFFixedDocument document = new PDFFixedDocument();
document.OptionalContentProperties = new PDFOptionalContentProperties();
PDFPage page = document.Pages.Add();
// Create an optional content group (layer) for the extracted page content.
PDFOptionalContentGroup ocg = new PDFOptionalContentGroup();
ocg.Name = "Embedded page";
ocg.VisibilityState = PDFOptionalContentGroupVisibilityState.AlwaysVisible;
ocg.PrintState = PDFOptionalContentGroupPrintState.NeverPrint;
// Draw the extracted page content in the layer
page.Canvas.BeginOptionalContentGroup(ocg);
page.Canvas.DrawFormXObject(pageContent, 0, 0, page.Width, page.Height);
page.Canvas.EndOptionalContentGroup();
// Build the display tree for the optional content
PDFOptionalContentDisplayTreeNode ocgNode = new PDFOptionalContentDisplayTreeNode(ocg);
document.OptionalContentProperties.DisplayTree.Nodes.Add(ocgNode);
using (FileStream output = File.Create("EmbedPageAsLayer.pdf"))
{
document.Save(output);
}
The output PDF file is available here: https://github.com/o2solutions/pdf4net/blob/master/GettingStarted/EmbedPageAsLayer/EmbedPageAsLayer.pdf

How to get the path of an Image Field in a pdf form, in Adobe?

I am creating a PDF form using adobe reader. I have added an image field and a text box. The text box is read-only and I want to populate the text box with the path of the image selected by the end-user, in the image field. Following is my code:
var one = this.getField("Image1");
var two = this.getField("Text1");
two.value='The Path';
The above code runs normally but I can't figure out as to what to write instead of 'The Path', to get the actual path of the image selected by the end-user.
P.S.
On the Image1 button there are 2 actions:
Mouse Up(execute Js)
event.target.buttonImportIcon();
On Blur(execute Js)
var one = this.getField("Image1");
var two = this.getField("Text1");
two.value='The Path';
If I am understanding your request correctly... Assuming that Image1 is a button field and Text1 is a text field and you want the selected image file to appear as the button icon, the code would be as follows...
var one = this.getField("Image1");
var two = this.getField("Text1");
var doc = app.browseForDoc(); // Allows the user to browse for a file
var docPath = doc.cPath; // gets the file path of the selected file
one.buttonImportIcon(docPath); // uses the selected path to import the image as the "normal" or "up" button icon
two.value = docPath; // set the value of the text field to the selected device independent path

Loading images asynchronously in windows 8 metro apps

I am new to Windows 8 app development. In my app I need to display a GridView with images and title. The image URL and the title I get from the server as a XML data. The images are downloaded from the given URL and stored in a local directory. Now, when an image is downloaded I want to notify the GridView and update the particular image view with the downloaded image. I store the title and the local image URI in an ObservableCollection. The data source of the GridView is bound to this ObservableCollection, so once the XML data is downloaded I am able to update the title through the ObservableCollection. But i don't know how to update the images once they are downloaded.
Assuming that your image is saved in the local data folder (ApplicationData.Current.LocalFolder) - you can create a new BitmapImage this way:
var imagePathInLocalDataFolder = ?
var imageUri = new Uri("ms-appdata:///local/" + imagePathInLocalDataFolder, UriKind.Absolute);
var bitmapImage = new BitmapImage(new Uri(imageUri));
You can then assign the bitmapImage variable value to a property that you bind to an Image.Source - and you should see your image.

cannot load image in isolated storage when creating IconicTile

I'm trying to create IconicTile using image saved on isolated storage.
At first, I saved image to isolated storage.
// bitmap is Stream of image source (e.g. from PhotoChooserTask)
var wbmp = new WriteableBitmap(bitmap);
var file = "Shared/ShellContent/IconicTile.png";
// when file exists, delete it
if (storage.FileExists(file))
{
storage.DeleteFile(file);
}
using (var isoFileStream = new IsolatedStorageFileStream(file, FileMode.Create, storage))
{
// use ToolStackPNGWriterExtensions
wbmp.WritePNG(isoFileStream);
}
And I have confirmed PNG file is successfully created using Isostorage Explorer Tools.
Then I try to create IconicTile.
var initialData = new IconicTileData
{
BackgroundColor = SelectedColor,
IconImage = new Uri("isostore:/Shared/ShellContent/IconicTile.png", UriKind.Absolute),
Title = tbTitle.Text,
WideContent1 = tbWideContent1.Text,
WideContent2 = tbWideContent2.Text,
WideContent3 = tbWideContent3.Text
};
var uri = string.Format("/SecondaryPage.xaml");
var TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(uri));
if (TileToFind == null)
ShellTile.Create(new Uri(uri, UriKind.Relative), initialData, true);
else
TileToFind.Update(initialData);
But image in the created tile are white.
(I'd like to attach image but my reputation is too low. Sorry.)
I tried not only PNG format but also JPG format, but neither doesn't work.
Is there anyway to create IconicTile using image on IsolatedStorage?
The iconic tile format expects a transparent background, based on your comment at the first line (PhotoChooserTask), I suspect you're using some type of image with no transparency.