|
Greetings, I am not sure about Icon, but I used your code and loaded a png without problem.
BitmapImage bi = new BitmapImage();
MemoryStream stream = new MemoryStream();
Bitmap bmp = new Bitmap(@"C:\Temp\Test.png");
bi.BeginInit();
bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
stream.Seek(0, SeekOrigin.Begin);
bi.StreamSource = stream;
bi.EndInit();
AppIcon = bi;
Check if it's the problem for loading Icon (try load a bmp or png).
I suggest the loading code should be placed in MyObject, your BitmapImage may be created by different thread as MyObject.
Regards
Joseph Leung
|
|
|
|
|
Thanks for your inputs.
The code that I pasted works. There are no issues .
I wanted to know if there could be possible memory leaks with my code....
Sunil
|
|
|
|
|
Greetings
Sorry I assumed your code has error in it
as Abhinav S said, there are no leaks, if you checked Bitmap.GetHbitmap() in MSDN you can find more information about the leak.
Thanks for posting your code, I just learnt that I can set SourceStream in BitmapImage directly, but I believe my code use less memory and faster however (Bitmap vs Bitmap + MemoryStream).
Regards
Joseph Leung
|
|
|
|
|
|
sunilkpv wrote: Well this is what I have implemented. Can you tell me whether this code will also lead to memory leaks.
I dont think so - I dont see any calls to unmanaged code in there.
However, it is always good practise to wrap a MemoryStream object within a using statement (as shown here).
|
|
|
|
|
I am trying to put several images dynamically onto a canvas. The images are of bigger size (e.g. 9 MB on disc, 200 MB of physical memory when decoded, resolution of 10200 x 7019, 600DPI).
If I add 2 images, everything is working fine. If I try to add another image, the Image is there on the canvas (meaning it reacts on mouse events) but it is not rendered - meaning it is invisible. I have about 1 GB of free physical memory available. When 2 images are loaded I still have 600 MB of free physical memory - but I cant load any more images. I tried to set the images' DecodeBitmapWith/Height attributes to have a smaller rendersize, but images are rendered black or look weird. Image.Rendersize attribute doesnt work in this context.
I have tried combining 3 big sized images with IrfanView -> same problem. Adobe Photoshop on the other side can handle all 3 Images and display them though PS also consumes nearly 700 MB of phys. memory.
I assume it has something to do with memory management. For better understanding here is my code:
ofd = new OpenFileDialog();
if ((bool)ofd.ShowDialog(this))
{
string[] images = ofd.FileNames;
foreach (string image in images)
{
Uri imgsource = new Uri(image);
BitmapImage bim = new BitmapImage();
bim.BeginInit();
bim.DecodePixelHeight = 10200;
bim.CacheOption = BitmapCacheOption.OnLoad;
bim.UriSource = imgsource;
bim.EndInit();
Image img = new Image();
img.Source = bim
canvas1.Children.Add(img);
img.AllowDrop = true;
Canvas.SetLeft(img, (canvas1.Children.Count)* 20);
Canvas.SetTop(img, (canvas1.Children.Count) * 20);
}
I hope anyone can help me with this.
Thanks in advance and best regards
Nick
|
|
|
|
|
Im guessing you are hitting the memory limit of the GPU. You might want to try TransformedBitmap and scale it that way, I quickly tested this with BitmapCacheOption.None and it seemed to only take up memory for the scaled image. As for the images looking wierd it may be due to a bug in WIC you may need get an updated version. Try Vista SP2 and the Platform Update For Windows Vista
modified on Wednesday, May 5, 2010 3:00 PM
|
|
|
|
|
Thank you very much for your input.
I was also thinking about only having a scaled image in memory and discarding the original sized one. But this would require a lot of additional calculation. What I am trying to do is implementing an application that is capable of combining single images into one image. E.g. an architect's plan (ANSI C) is scanned in into 3 ANSI B paper sized images. Those images are now loaded into my app, repositioned and then combined. The result should be the original plan with respect to its original size, DPI etc.
I was hoping there is another soluion, since Adobe Photoshop is capable of holding all 3 images in memory keeping the original sizes.
But I am starting working on algorithms that will work on scaled images.
best Regards
Dominik
|
|
|
|
|
Good day,
I am developing a system and I have been faced with a situation where I need to store all my forms into a database and all the controls so that at user registration one configures what should be displayed.
Could someone point me to a tutorial or sample code that can hint on this..
Thank you.
Give the world the best you have, And the best will come your Way
|
|
|
|
|
This is a relatively complicated task. Let's ignore the retrieval of the data from the database, the main issue you will face is hooking events up. This post[^] by Rob Relyea contains a lot of information that you will need.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I want to create random image appear when it's loaded.. the image use png or jpeg.. When the first image appear (2 images appear), we click other button beside the image.. then the second image appear again with different number (3 or 4 images appear).. and so on. Anyone can give me an example...
|
|
|
|
|
Hi yuripon,
You can use the Random number generator to randomize the collection. You can put the image name in an array and then using the rand.Next() you can load the next image. If you are not sure on which images will be present there, you can get the image list using an web service and then use the randomization to load the images.
Let me know, if you need further informations.
Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.
Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial
|
|
|
|
|
I open visual studio, create a new WPF Browser Application, without making any changes I hit the debug icon...And i get this error...I have tried this in both Visual Studio 2008 and 2010. Any ideas? Error Message (From VS 2010) is:
Startup URI: C:\Documents and Settings\Pablo & Carrie\Local Settings\Application Data\Temporary Projects\WpfBrowserApplication1\bin\Debug\WpfBrowserApplication1.xbap
Application Identity: file:///C:/Documents%20and%20Settings/Pablo%20%26%20Carrie/Local%20Settings/Application%20Data/Temporary%20Projects/WpfBrowserApplication1/bin/Debug/WpfBrowserApplication1.xbap#WpfBrowserApplication1.xbap, Version=1.0.0.0, Culture=neutral, PublicKeyToken=62048a9edceacdff, processorArchitecture=msil/WpfBrowserApplication1.exe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=62048a9edceacdff, processorArchitecture=msil, type=win32
System.ArgumentException: Value does not fall within the expected range.
at System.Deployment.Internal.Isolation.IDefinitionAppId.EnumAppPath()
at System.ActivationContext.CreateFromNameAndManifests(ApplicationIdentity applicationIdentity, String[] manifestPaths)
at System.Windows.Interop.ApplicationLauncherXappDebug.Initialize()
at System.Windows.Interop.DocObjHost.MS.Internal.AppModel.IBrowserHostServices.Run(String path, String fragment, MimeType mime, String debugSecurityZoneURL, String applicationId, Object streamContainer, Object ucomLoadIStream, String userAgentString, Boolean isDebugMode, Boolean isBrowserLowIntegrityProcess, INativeProgressPage nativeProgressPage, String progressAssemblyName, String progressClassName, String errorAssemblyName, String errorClassName)
-----------------------
PresentationHost.exe v4.0.40305.0 built by: Main - C:\WINDOWS\system32\PresentationHost.exe
ntdll.dll v5.1.2600.5755 (xpsp_sp3_gdr.090206-1234) - C:\WINDOWS\system32\ntdll.dll
kernel32.dll v5.1.2600.5781 (xpsp_sp3_gdr.090321-1317) - C:\WINDOWS\system32\kernel32.dll
ADVAPI32.dll v5.1.2600.5755 (xpsp_sp3_gdr.090206-1234) - C:\WINDOWS\system32\ADVAPI32.dll
RPCRT4.dll v5.1.2600.5795 (xpsp_sp3_gdr.090415-1241) - C:\WINDOWS\system32\RPCRT4.dll
Secur32.dll v5.1.2600.5834 (xpsp_sp3_gdr.090624-1305) - C:\WINDOWS\system32\Secur32.dll
USER32.dll v5.1.2600.5512 (xpsp.080413-2105) - C:\WINDOWS\system32\USER32.dll
GDI32.dll v5.1.2600.5698 (xpsp_sp3_gdr.081022-1932) - C:\WINDOWS\system32\GDI32.dll
ole32.dll v5.1.2600.5512 (xpsp.080413-2108) - C:\WINDOWS\system32\ole32.dll
msvcrt.dll v7.0.2600.5512 (xpsp.080413-2111) - C:\WINDOWS\system32\msvcrt.dll
OLEAUT32.dll v5.1.2600.5512 - C:\WINDOWS\system32\OLEAUT32.dll
mscoree.dll v4.0.31106.0 (Main.031106-0000) - C:\WINDOWS\system32\mscoree.dll
SHLWAPI.dll v6.00.2900.5912 (xpsp_sp3_gdr.091207-1454) - C:\WINDOWS\system32\SHLWAPI.dll
WININET.dll v8.00.6001.18904 (longhorn_ie8_gdr.100222-1700) - C:\WINDOWS\system32\WININET.dll
Normaliz.dll v6.0.5441.0 (winmain(wmbla).060628-1735) - C:\WINDOWS\system32\Normaliz.dll
urlmon.dll v8.00.6001.18904 (longhorn_ie8_gdr.100222-1700) - C:\WINDOWS\system32\urlmon.dll
iertutil.dll v8.00.6001.18904 (longhorn_ie8_gdr.100222-1700) - C:\WINDOWS\system32\iertutil.dll
SHELL32.dll v6.00.2900.5622 (xpsp_sp3_gdr.080617-1319) - C:\WINDOWS\system32\SHELL32.dll
IMM32.DLL v5.1.2600.5512 (xpsp.080413-2105) - C:\WINDOWS\system32\IMM32.DLL
comctl32.dll v6.0 (xpsp.080413-2105) - C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83\comctl32.dll
PresentationHost_v0400.dll v4.0.30319.1 built by: RTMRel - C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\WPF\PresentationHost_v0400.dll
MSVCR100_CLR0400.dll v10.00.30319.1 - C:\WINDOWS\system32\MSVCR100_CLR0400.dll
VERSION.dll v5.1.2600.5512 (xpsp.080413-2105) - C:\WINDOWS\system32\VERSION.dll
PSAPI.DLL v5.1.2600.5512 (xpsp.080413-2105) - C:\WINDOWS\system32\PSAPI.DLL
uxtheme.dll v6.00.2900.5512 (xpsp.080413-2105) - C:\WINDOWS\system32\uxtheme.dll
MSCTF.dll v5.1.2600.5512 (xpsp.080413-2105) - C:\WINDOWS\system32\MSCTF.dll
CLBCATQ.DLL v2001.12.4414.700 - C:\WINDOWS\system32\CLBCATQ.DLL
COMRes.dll v2001.12.4414.700 - C:\WINDOWS\system32\COMRes.dll
xpsp2res.dll v5.1.2600.5512 (xpsp.080413-2113) - C:\WINDOWS\system32\xpsp2res.dll
ws2_32.dll v5.1.2600.5512 (xpsp.080413-0852) - C:\WINDOWS\system32\ws2_32.dll
WS2HELP.dll v5.1.2600.5512 (xpsp.080413-0852) - C:\WINDOWS\system32\WS2HELP.dll
dfshim.dll v4.0.31106.0 (Main.031106-0000) - C:\WINDOWS\system32\dfshim.dll
mscoreei.dll v4.0.30319.1 (RTMRel.030319-0100) - C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll
clr.dll v4.0.30319.1 (RTMRel.030319-0100) - C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
msxml3.dll v8.100.1051.0 - C:\WINDOWS\system32\msxml3.dll
PresentationHostDLL.dll v3.0.6920.1427 built by: SP - C:\WINDOWS\Microsoft.NET\Framework\v3.0\WPF\PresentationHostDLL.dll
MSVCR80.dll v8.00.50727.4027 - C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.4027_x-ww_e69378d0\MSVCR80.dll
actxprxy.dll v6.00.2900.5512 (xpsp.080413-2113) - C:\WINDOWS\system32\actxprxy.dll
PresentationHostProxy.dll v4.0.31106.0 built by: Main - C:\WINDOWS\system32\PresentationHostProxy.dll
msctfime.ime v5.1.2600.5512 (xpsp.080413-2105) - C:\WINDOWS\system32\msctfime.ime
mscorwks.dll v2.0.50727.3603 (GDR.050727-3600) - C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
mscorlib.ni.dll v2.0.50727.3603 (GDR.050727-3600) - C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\7124a40b9998f7b63c86bd1a2125ce26\mscorlib.ni.dll
System.ni.dll v2.0.50727.3053 (netfxsp.050727-3000) - C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System\3de5bd01124463d7862bd173af90bc83\System.ni.dll
WindowsBase.ni.dll v3.0.6920.1427 built by: SP - C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\WindowsBase\204d6e5b335134f23ca37638b9227ecf\WindowsBase.ni.dll
PresentationCore.ni.dll v3.0.6920.1427 built by: SP - C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\PresentationCore\94badbd64df59de7da249f71da38b1c2\PresentationCore.ni.dll
PresentationFramework.ni.dll v3.0.6920.1500 built by: QFE - C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\PresentationFramewo#\58c7ac6b6054038dc9346d7ec8e32b4c\PresentationFramework.ni.dll
wpfgfx_v0300.dll v3.0.6920.1500 built by: QFE - C:\WINDOWS\Microsoft.NET\Framework\v3.0\WPF\wpfgfx_v0300.dll
System.Xml.ni.dll v2.0.50727.3082 (QFE.050727-3000) - C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System.Xml\5913d3f81e77194ec833991b1047a532\System.Xml.ni.dll
diasymreader.dll v8.0.50727.3053 (netfxsp.050727-3000) - C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\diasymreader.dll
--
"Keyboard not found. Press < F1 > to RESUME. "
Source unknown (appears in many common BIOSes as a real error message)
|
|
|
|
|
Hi ...
I got same problem ....
Its very Urgent help me ...
thanks in advance ..
Error Details ...
Startup URI: C:\Working Folder\S&OP System\WpfBrowserApplicationTest\WpfBrowserApplicationTest\bin\Debug\WpfBrowserApplicationTest.xbap
Application Identity: file:///C:/Working%20Folder/S%26OP%20System/WpfBrowserApplicationTest/WpfBrowserApplicationTest/bin/Debug/WpfBrowserApplicationTest.xbap#WpfBrowserApplicationTest.xbap, Version=1.0.0.0, Culture=neutral, PublicKeyToken=251d351ee89460b3, processorArchitecture=msil/WpfBrowserApplicationTest.exe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=251d351ee89460b3, processorArchitecture=msil, type=win32
System.ArgumentException: Value does not fall within the expected range.
at System.Deployment.Internal.Isolation.IDefinitionAppId.EnumAppPath()
at System.ActivationContext.CreateFromNameAndManifests(ApplicationIdentity applicationIdentity, String[] manifestPaths)
at System.ActivationContext.CreatePartialActivationContext(ApplicationIdentity identity, String[] manifestPaths)
at System.Windows.Interop.ApplicationLauncherXappDebug.Initialize()
at System.Windows.Interop.DocObjHost.MS.Internal.AppModel.IBrowserHostServices.Run(String path, String fragment, MimeType mime, String debugSecurityZoneURL, String applicationId, Object streamContainer, Object ucomLoadIStream, HostingFlags hostingFlags, INativeProgressPage nativeProgressPage, String progressAssemblyName, String progressClassName, String errorAssemblyName, String errorClassName, IHostBrowser hostBrowser)
-----------------------
PresentationHost.exe v4.0.40305.0 built by: Main - C:\WINDOWS\system32\PresentationHost.exe
ntdll.dll v5.2.3790.4455 (srv03_sp2_gdr.090203-1205) - C:\WINDOWS\system32\ntdll.dll
kernel32.dll v5.2.3790.4480 (srv03_sp2_gdr.090321-1244) - C:\WINDOWS\system32\kernel32.dll
ADVAPI32.dll v5.2.3790.4555 (srv03_sp2_gdr.090718-1230) - C:\WINDOWS\system32\ADVAPI32.dll
RPCRT4.dll v5.2.3790.4759 (srv03_sp2_gdr.100817-0343) - C:\WINDOWS\system32\RPCRT4.dll
Secur32.dll v5.2.3790.4530 (srv03_sp2_gdr.090615-1611) - C:\WINDOWS\system32\Secur32.dll
USER32.dll v5.2.3790.4033 (srv03_sp2_gdr.070228-0030) - C:\WINDOWS\system32\USER32.dll
GDI32.dll v5.2.3790.4396 (srv03_sp2_gdr.081022-1212) - C:\WINDOWS\system32\GDI32.dll
ole32.dll v5.2.3790.4750 (srv03_sp2_gdr.100723-0347) - C:\WINDOWS\system32\ole32.dll
msvcrt.dll v7.0.3790.3959 (srv03_sp2_rtm.070216-1710) - C:\WINDOWS\system32\msvcrt.dll
OLEAUT32.dll v5.2.3790.4202 - C:\WINDOWS\system32\OLEAUT32.dll
mscoree.dll v4.0.31106.0 (Main.031106-0000) - C:\WINDOWS\system32\mscoree.dll
SHLWAPI.dll v6.00.3790.4603 (srv03_sp2_gdr.091015-1453) - C:\WINDOWS\system32\SHLWAPI.dll
WININET.dll v7.00.6000.17091 (vista_gdr.100824-1500) - C:\WINDOWS\system32\WININET.dll
Normaliz.dll v6.0.5441.0 (winmain(wmbla).060628-1735) - C:\WINDOWS\system32\Normaliz.dll
iertutil.dll v7.00.6000.17091 (vista_gdr.100824-1500) - C:\WINDOWS\system32\iertutil.dll
urlmon.dll v7.00.6000.17091 (vista_gdr.100824-1500) - C:\WINDOWS\system32\urlmon.dll
SHELL32.dll v6.00.3790.4751 (srv03_sp2_gdr.100726-0339) - C:\WINDOWS\system32\SHELL32.dll
IMM32.DLL v5.2.3790.3959 (srv03_sp2_rtm.070216-1710) - C:\WINDOWS\system32\IMM32.DLL
LPK.DLL v5.2.3790.3959 (srv03_sp2_rtm.070216-1710) - C:\WINDOWS\system32\LPK.DLL
USP10.dll v1.0422.3790.4695 (srv03_sp2_gdr.100416-1721) - C:\WINDOWS\system32\USP10.dll
winmm.dll v5.2.3790.3959 (srv03_sp2_rtm.070216-1710) - C:\WINDOWS\system32\winmm.dll
comctl32.dll v6.0 (srv03_sp2_qfe.100903-0347) - C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.3790.4770_x-ww_05FDF087\comctl32.dll
PresentationHost_v0400.dll v4.0.30319.1 built by: RTMRel - C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\WPF\PresentationHost_v0400.dll
MSVCR100_CLR0400.dll v10.00.30319.1 - C:\WINDOWS\system32\MSVCR100_CLR0400.dll
VERSION.dll v5.2.3790.3959 (srv03_sp2_rtm.070216-1710) - C:\WINDOWS\system32\VERSION.dll
PSAPI.DLL v5.2.3790.3959 (srv03_sp2_rtm.070216-1710) - C:\WINDOWS\system32\PSAPI.DLL
MSCTF.dll v5.2.3790.3959 (srv03_sp2_rtm.070216-1710) - C:\WINDOWS\system32\MSCTF.dll
CLBCatQ.DLL v2001.12.4720.3959 (srv03_sp2_rtm.070216-1710) - C:\WINDOWS\system32\CLBCatQ.DLL
COMRes.dll v2001.12.4720.3959 (srv03_sp2_rtm.070216-1710) - C:\WINDOWS\system32\COMRes.dll
xpsp2res.dll v5.2.3790.3959 (srv03_sp2_rtm.070216-1710) - C:\WINDOWS\system32\xpsp2res.dll
netapi32.dll v5.2.3790.4392 (srv03_sp2_gdr.081016-1620) - C:\WINDOWS\system32\netapi32.dll
ws2_32.dll v5.2.3790.3959 (srv03_sp2_rtm.070216-1710) - C:\WINDOWS\system32\ws2_32.dll
WS2HELP.dll v5.2.3790.3959 (srv03_sp2_rtm.070216-1710) - C:\WINDOWS\system32\WS2HELP.dll
dfshim.dll v4.0.31106.0 (Main.031106-0000) - C:\WINDOWS\system32\dfshim.dll
mscoreei.dll v4.0.30319.1 (RTMRel.030319-0100) - C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll
clr.dll v4.0.30319.1 (RTMRel.030319-0100) - C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
msxml3.dll v8.100.1051.0 - C:\WINDOWS\system32\msxml3.dll
msi.dll v4.5.6001.22299 - C:\WINDOWS\system32\msi.dll
ACTXPRXY.DLL v6.00.3790.3959 (srv03_sp2_rtm.070216-1710) - C:\WINDOWS\system32\ACTXPRXY.DLL
SXS.DLL v5.2.3790.3959 (srv03_sp2_rtm.070216-1710) - C:\WINDOWS\system32\SXS.DLL
PresentationHostProxy.dll v4.0.31106.0 built by: Main - C:\WINDOWS\system32\PresentationHostProxy.dll
IEPROXY.DLL v7.00.5730.13 (longhorn(wmbla).070711-1130) - C:\Program Files\Internet Explorer\IEPROXY.DLL
apphelp.dll v5.2.3790.3959 (srv03_sp2_rtm.070216-1710) - C:\WINDOWS\system32\apphelp.dll
msctfime.ime v5.2.3790.3959 (srv03_sp2_rtm.070216-1710) - C:\WINDOWS\system32\msctfime.ime
culture.dll v4.0.30319.1 (RTMRel.030319-0100) - C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\culture.dll
mscorlib.ni.dll v4.0.30319.1 (RTMRel.030319-0100) - C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\mscorlib\246f1a5abb686b9dcdf22d3505b08cea\mscorlib.ni.dll
nlssorting.dll v4.0.30319.1 (RTMRel.030319-0100) - C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\nlssorting.dll
System.ni.dll v4.0.30319.1 built by: RTMRel - C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\System\964da027ebca3b263a05cadb8eaa20a3\System.ni.dll
WindowsBase.ni.dll v4.0.30319.1 built by: RTMRel - C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\WindowsBase\d17606e813f01376bd0def23726ecc62\WindowsBase.ni.dll
rsaenh.dll v5.2.3790.3959 (srv03_sp2_rtm.070216-1710) - C:\WINDOWS\system32\rsaenh.dll
PresentationCore.ni.dll v4.0.30319.1 built by: RTMRel - C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\PresentationCore\3963e9ce8d44f50e8367e92a8e3e42e6\PresentationCore.ni.dll
PresentationFramework.ni.dll v4.0.30319.1 - C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\PresentationFramewo#\7f91eecda3ff7ce478146b6458580c98\PresentationFramework.ni.dll
wpftxt_v0400.dll v4.0.30319.1 built by: RTMRel - C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\WPF\wpftxt_v0400.dll
wpfgfx_v0400.dll v4.0.30319.1 built by: RTMRel - C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\WPF\wpfgfx_v0400.dll
PresentationNative_v0400.dll v4.0.30319.1 built by: RTMRel - C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\WPF\PresentationNative_v0400.dll
System.Xaml.ni.dll v4.0.30319.1 built by: RTMRel - C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\System.Xaml\035910922f160d304fb834aae41f45a6\System.Xaml.ni.dll
clrjit.dll v4.0.30319.1 (RTMRel.030319-0100) - C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clrjit.dll
System.Xml.ni.dll v4.0.30319.1 built by: RTMRel - C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\System.Xml\e997d0200c25f7db6bd32313d50b729d\System.Xml.ni.dll
diasymreader.dll v10.0.30319.1 built by: RTMRel - C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\diasymreader.dll
ghghgh
|
|
|
|
|
Using SL3/VS2008:
I'm (still) trying to render text on a bitmap. Tim Yen suggested using WriteableBitmap , and even that doesn't seem to work for me. I've tried it two different ways:
Label label = new Label();
label.Style = this.Resources["TitleBaseStyle"] as Style;
label.Content = "WHMC";
<br />
WriteableBitmap bmp = new WriteableBitmap(60, 60);
bmp.Render(label, new TranslateTransform());
bmp.Invalidate();
<br />
Image image = new Image();
image.HorizontalAlignment = HorizontalAlignment.Center;
image.VerticalAlignment = VerticalAlignment.Center;
image.Width=60;
image.Height=60;
image.Source = bmp;
this.testImage.Child = image;
...and...
Label label = new Label();
label.Style = this.Resources["TitleBaseStyle"] as Style;
label.Content = "WHMC";
<br />
WriteableBitmap bmp = new WriteableBitmap(label, new TranslateTransform());
<br />
Image image = new Image();
image.HorizontalAlignment = HorizontalAlignment.Center;
image.VerticalAlignment = VerticalAlignment.Center;
image.Width=60;
image.Height=60;
image.Source = bmp;
this.testImage.Child = image;
In the interest of completeness, here's the label's custom style:
<Style x:Key="TitleBaseStyle" TargetType="dataInput:Label">
<Setter Property="Width" Value="60" />
<Setter Property="Height" Value="30" />
<Setter Property="Background" Value="Black" />
<Setter Property="Foreground" Value="White" />
<Setter Property="FontSize" Value="17" />
<Setter Property="Padding" Value="0" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
...and here's the container for the image:
<Border x:Name="testImage" BorderBrush="Black" Background="Red" BorderThickness="1" Margin="10"/>
Neither method results in an Image with anything visible in it (all the pixels in the WriteableBitmap object are null). This is driving me insane. What the hell am I doing wrong?
Just to make sure the label was being created as expected, I also did this, and it is displayed as expected:
Label label = new Label();
label.Style = this.Resources["TitleBaseStyle"] as Style;
label.Content = "WHMC";
this.testImage.Child = label;
I'm at a total loss...
EDIT ==================
I downloaded the WriteableBitmapEx assembly from codeplex because it contains a Clear(Color) method (like the GDI Bitmap class does). If I don't call bmp.Render(label) , the image does in fact get displayed. If I put the bmp.Render(label) back into the code, the image does NOT display.
Side note: If I call bmp.Clear(Color.Transparent) (and remove the Render(label) line), the rendered image has a whiteground, despite the Image object being placed in a red-filled Border container.
WTF?
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
|
Well, that was the beta version of SL3. In the release version the Lock functionality is missing, as is the ability to set the PixelFormat via a constructor parameter.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Hi John,
I wrote this very quick and it seems to work just fine. The only thing is that you need to click the button twice!! That I dont know why?
<UserControl x:Class="SilverlightApplication5.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400" xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input">
<UserControl.Resources >
<Style x:Key="TitleBaseStyle" TargetType="dataInput:Label">
<Setter Property="Width" Value="60" />
<Setter Property="Height" Value="30" />
<Setter Property="Background" Value="Black" />
<Setter Property="Foreground" Value="White" />
<Setter Property="FontSize" Value="17" />
<Setter Property="Padding" Value="0" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
</Style>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="156,190,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
<dataInput:Label Style="{StaticResource TitleBaseStyle}" Height="23" HorizontalAlignment="Left" Margin="81,190,0,0" Name="label1" VerticalAlignment="Top" Width="57"/>
<Image Height="91" HorizontalAlignment="Left" Margin="137,93,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="110" />
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Media.Imaging;
namespace SilverlightApplication5
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
label1.Content = "WHMC";
WriteableBitmap bmp = new WriteableBitmap(60, 60);
bmp.Render(label1, new RotateTransform() { Angle = 0 });
bmp.Invalidate();
image1.HorizontalAlignment = HorizontalAlignment.Center;
image1.VerticalAlignment = VerticalAlignment.Center;
image1.Width = bmp.PixelWidth;
image1.Height = bmp.PixelHeight;
image1.Source = bmp;
}
}
}
|
|
|
|
|
|
Looking ta the code your using an Image in the XAML
John was using a Border
Good answer
|
|
|
|
|
I gave up on this and found another (albeit clunky) solution to the problem I was trying to solve (and the solution has nothing to do with drawing bitmaps, so there's no solution to this particular problem posted).
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
So Silverlight 4 gives us a RichTextBox, and the RichTextBox gives us an attribute to get the content in Xaml, but there is no way of getting the standard RTF text (compatible with the RTF 1.5 / 1.6 specification)... Or is there?
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
There is another[^] text box available for silverlight - not sure if this meet RTF specifications.
|
|
|
|
|
Thanks, but the replies further down mentions that it is not aligned with the standard RTF format
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
How do I add event to calendar ??
Do any control ready made available which allow me to add event to calendar
control of silverlight ??
Thx in Adv.
Jinal Desai - LIVE
|
|
|
|
|