JDialog - how to change icon - swing

I want to change icon of the JDialog (to replace standard java cup)
I am able to do that this way:
ImageIcon img = new ImageIcon(OuterClass.class.getResource("fileThatWorks.jpg"));
myJDialog.setIconImage(img.getImage());
Howerver when I replaced fileThatWorks.jpg with image.ico code stopped working.
I've tried to convert my image.ico to image.jpg but it didn't nelped.
What's wrong with my approach? Why it works for some *jpg files but doesn't work for *ico files?

The ImageIcon API states that the supported types are JPEG & GIF. Not too sure of a workaround for that.

Related

Reloading custom tool from svg markup string

I'm using the Markup Core extension and have created a custom tool with Edit Mode etc. The tool seems to be working fine on first adding to the canvas, dragging, resizing and on clicking save, I can see my new DotMarkup in the markups array.
However, when calling generateData and saving an svg string, an attempting to load the data onto a new layer using loadMarkups(svg, layerName) the custom markup is shown on screen but is unclickable, the markup is not visible in the markups arrays (on the editor, or in the svg markups array).
Any help appreciated
I've recently been looking into this as well, and unfortunately it turns out that exporting and re-importing custom markups is not yet supported by the MarkupsCore extension. If you look at the extension code and search for createMarkupFromSVG, you'll notice towards the end of the function that it's just a long switch with the built-in markup types. So, while your custom SVG is loaded, it's not considered a "markup SVG". To work around this issue you would probably have to parse the SVG string yourself and set the internal state of of the extension (such as this.markups) manually.

WebGL - change mapAmbient material property in Three.js

I'm trying to update an image in a material of a pre-loaded .js model - i want it to have the same properties, whereas only the image is changed.
Was trying to use this post as a reference, but in the .js model file, the map appears as the "mapAmbient" property. I was thinking of somehow using the THREE.ImageUtils.loadTexture() function, but couldn't find where exactly it should be placed.
Moreover, the texture should be loaded using an Image() object generated using another canvas. Any help would be appriciated
*Edit:
Wasn't able to find actual way to change that property in runtime, but was able to change the image using base64 encoding:
//img is base64 encoded image
var tex = new THREE.ImageUtils.loadTexture(img);
currentMesh.material.materials[1].map = tex;

How can I use a sprite to specify the pushpin png I want to use in a map?

After (probably) deciding on the jQuery map plugin to use (see What jQuery map plugin allows specifying the color of the pushpins?), I now need png files of colored pushpins.
I found a dandy one here: http://www.fuzzimo.com/free-vector-post-it-notes-push-pins/ :
...but it appears to be, not a collection of various png files I can use (blue.png, red.png, chartreuse.png, etc.) but one humongous .png file with an array of images. So I'm guessing this is meant to be used as a sprite. Being a sprite newby, though, I don't know how to use this image and specify the section of it that I want to use.
Specifically, the jQuery code I'll be using to set the marker's icon is like:
icon: '../img/apartment.png'
...how can I specify usage of a specific pushpin?

How to set Bitmap image in Canvas background? AS3

I have image as Bitmap:
var bitmapImage:Bitmap=getDefaultImage();
I need to set this bitmap as canvas backgroundImage.
I find method
myCanvas.setStyle("backgroundImage",url);
But i dont need url. Whent i do this:
myCanvas.setStyle("backgroundImage",bitmapImage);
I have an error.
How to set bitmap image in canvas background?
I am not sure if this is possible... You see, setStyle and getStyle in AS3.0 both work on CSS base. And in CSS there is nothing like Bitmap, just URLs, URIs, numeric, string and type values... Nothing for byte data.
So - either you use your Canvas wrong (don't use it at all maybe?), or, if you really need to use the setStyle method for this, you will have to use the URL... However, I think it might be possible to embed the file into the SWF... Not just with the Embed directive, but something like Flex project. It might be possible to address the file with local URL such as "myBitmap.png".

How to submit HTML and receive a bitmap?

I have an app that allows a user to use JQuery and Javascript to add images and position them in a div dynamically.
I would like to be able to submit the div with all the HTML to a WebService and receive back an image so we have a bitmap of the result of the end user's work.
I would prefer a solution in .Net as this is what I am most familiar with but am open to pretty much anything?
I would like to be able to submit the div with all the HTML to a WebService and receive back an image
Try http://browsershots.org!
Browsershots makes screenshots of your web design in different operating systems and browsers. It is a free open-source online web application providing developers a convenient way to test their website's browser compatibility in one place.
How about this. You load the html into a webbrowser control and then use the DrawToBitmap method. It doesn't show up on intellisense and this is probably not the best solution, but it works. Observe the DocumentCompleted event and add the following code:
private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
var bmp = new Bitmap(100, 100);
var rect = new Rectangle(webBrowser.Location.X, webBrowser.Location.Y, webBrowser.Width, webBrowser.Height);
webBrowser.DrawToBitmap(bmp, rect);
bmp.Save("test.jpg", ImageFormat.Jpeg);
}
You'll probably want to change the width and height of that bitmap object (do it in some smart way or something). Hope this helps.
EDIT: I see now that you are using a webservice for this, hence this solution probably won't work. I'll leave it here just for information's sake.
I was not able to figure out how to do this by submitting the html and receiving an image but I was able to create and ASHX handler that returns a png file based on this blog post
which was good enough for my scenario.
He uses CutyCapt to take a screen shot of an existing web page, write the image to a folder on the webserver and return it.