I was on the way of making a picasa like photo viewer and later an image editor.i used JFrame and alpha channel to set background transparent.but while moving or zooming in/out ,as i had to draw it on different location and clear the previous image i used clearRect and faced the problem.
the oracle documentation says it clears the rect and restores the background color.
on some trials the clearRect clears the area to background color.But while continuous events like mouse-dragging its turning the color of cleared area to black and causing this:
`
thnx
.i used JFrame and alpha channel to set background transparent.
Don't use alpha for complete transparency. Instead just use:
panel.setOpaque( false );
If you are using semi transparency then check out Backgrounds With Transparency. It will explain the problems with transparent background and provide a couple of solutions.
The basic problem is that transparency breaks the painting contract with Swing components because the background is not cleared entirely before child components are painted.
Related
I have a Processing.js sketch that must be transparent. I figured out how to set the background to be transparent by default, however, when I draw on the sketch I seemed to have permanently marked the canvas.
Is it possible to clear the canvas and set it back to transparent using Processing.js?
If not, is context.clearRect(params) fast enough/ a suitable solution?
Here are the first two results for googling "Processing.js transparent background":
http://processingjs.org/reference/transparent/
http://processingjs.org/reference/background_/
(Even without google, the reference should be your first stop for questions like this.)
Anyway, yes you can use a transparent background. Just use the /* #pjs transparent="true"; */ directive at the top of your code to enable transparency, and then pass an alpha value into the background() function.
I am using PNG images as main image resource in my application. Since im using Delphi 7, i downloaded PNGImage lib and included it in project. I load images like this:
Form.image.Picture.LoadFromFile(PAnsiChar('\background.png'));
Image has transparent and semi transparent pixels on its border. The problem i get is that transparent pixels are filled with random zoomed part of my desktop with currently opened windows, while i expected to see what is actually located beneath form.
Additionally, form has this properties:
BorderStyle: bsNone;
TransparentColor: true;
Visible: false;
Here is a picture of current state (above black line) and desired:
Can this be fixed somehow or it is how delphi deals with transparency?
To have the form "shade" what's beneath it, use the forms AlphaBlend and AlphaBlendValue properties. The .png image doesn't have to be partially (alpha blended) transparent, but it can be.
If you want the form to be semi-transparent you use Alphablending, that's a limitation of Windows. In addition you can have a certain color fully transparent. In the following sample the forms color is clGray, which is also defined as the Transparent color property in addition to the Transparent property set to True. The image, aligned alClient, is 50% transparent, placed on a TImage which is set as transparent, but even so, it doesn't show up as semi-transparent unless you have AlphaBlending on. Again, this is a limitation of Windows. The best you can do is try with a fairly high value for AlphaBlendingValue (240..250) and a rather light image to find the right compromise.
I have a collection of HubTiles with user-selected images. If an image with transparency is selected, the HubTile's background color (PhoneAccentBrush) shows through. Is there a way to style just the photo background to Transparent without altering the animation backgrounds? (Although if the Title is displayed on a transparent background, that's acceptable, but I'd still like the flipside to use the accent color.)
I've done some searching on styling the HubTile, but haven't been successful.
Apparently the fastest way to find an answer on the interwebs is to post your question to SO. I found this not two minutes after posting.
Konstantinos Kyriakopoulos has a blog post with the template styling I was looking for. I couldn't set the image background to Transparent, but I was able to set it to PhoneBackgroundBrush, which works just as well.
Specifically, I set the Background of the Border in the TitlePanel Grid.
I'm using Linux and I would like to create a transparent window and load in it an image with an alpha channel, so that the windows below show through the alpha channel. What's the simplest way of doing this? I'd use Python if possible, but I'm not fussy.
You can't directly do it with X11. It does not know what transparency is.
In order to draw a translucent window, your window manager (which must be a COMPOSITE window manager) has to provide this function.
So try studying your WM specs and see if and how it handles transparency.
First of all I will explain my situation so you can know my problem a little better. I'm making a HTML5 app. I have a canvas, and using a color picker you can change the color of the canvas. Now i have a picture which I want to put on the canvas but that pictures color needs to be changed using a color picker. So i need to replace, lets say, black color on that picture and put it on the canvas so it dosnt screw up the background.
So that will look like this:
1st color picker- changes the color of the canvas
2nd color picker - replaces the black color on the image with the one in the color picker and puts it on the canvas
Now my problem is how to replace the color on the image without reloading the page.
My only condition is no using silverlight, flash, java or any other similar tehnology that need 3rd party software to be installed on the device.
Thanks in advance.
If you dont understand my query fully, feel free to ask.
My approach with a JS only solution could be:
Loading the image inside a canvas element. Look at the MDC canvas tutorial
Trigger the user click on the canvas and get the pixel color (see links below to know how to get the color of a pixel) and look at this answer to get the mouse position
Substitute all the colors in the canvas with the one the user pick. For some examples about pixel manipulation:
Pushing pixel with canvas at Mozilla Hacks
http://beej.us/blog/2010/02/html5s-canvas-part-ii-pixel-manipulation/
This JS at mezzoblue apply heavy filter to an image
After some canvas experiment I notice that mostly in all the browser the pixel manipulation with canvas could be very slow also with small images. So another experiment to do could be to get the pixel color and then:
pass the color information to a PHP (or another server side script) with an AJAX call
do the color manipulation with an image library like GD or imagemagik
return back your image with the Ajax response
reload your canvas with the modified version of the image