小编yr_*_*eng的帖子

Windows Phone 8中BitmapImage/Image控件的内存消耗

我正在测试一个WP8应用程序和它的图像查看器来显示许多图像,我发现应用程序的内存消耗正在提高,并希望找到如何解决它.

我已经从网上阅读了一些文章,但这些文章提供的解决方案不适用于我的应用,请阅读以下历史记录.

首先,我发现文章" Windows Phone 7的图像提示 "并下载其样本进行清洁图像缓存测试,它使用的是1张图像.

然后出于测试目的,我使用应用程序内的15个离线图像编译此应用程序,并设置为"内容",请从此处下载测试应用程序.

我的测试步骤是:

(1) Launch app
(2) Go to Image Caching page
(3) Enable checkbox "Avoid Image Caching"
(4) Continuously tapping button Show/Clear
(5) Keep watching the memory status textblock at the bottom
Run Code Online (Sandbox Code Playgroud)

当我测试我的应用程序时,内存正在提升,如16.02MB =>显示(19.32MB)=>清除(16.15MB)=>显示(20.18MB)=>清除(17.03MB)...等和内存即使离开缓存页面再次进入缓存页面也不会被释放.似乎文章" Windows Phone 7的图像提示 "的解决方案仅适用于1个图像.

这是" Windows Phone 7的图像提示 "解决方案的xaml和代码隐藏.

[Caching.xaml]

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <StackPanel Orientation="Horizontal" VerticalAlignment="Top">
                <ToggleButton Content="Show" Width="150" Checked="ShowImageClicked" Unchecked="ClearImageClicked"/>
                <CheckBox x:Name="cbAvoidCache" Content="Avoid Image …
Run Code Online (Sandbox Code Playgroud)

c# out-of-memory bitmapimage windows-phone-8

9
推荐指数
1
解决办法
7402
查看次数

如何在Windows Store应用程序中使用WinRT C++中的"字节数组"获取结构数组?

在这里,我有一个带有C++ WinRT组件的C#metro app.我需要在WinRT中做一些事情,比如分配照片的名称/路径,并检索照片的缩略图.

首先,我在WinRT C++中编写一个值struct并检索struct array函数,如下所示.

public value struct Item
{
    String^ strName;
    String^ strPath;
};
public ref class CTestWinRT sealed
{
public:
    CTestWinRT();
    void TestOutStructArray(Platform::WriteOnlyArray<Item>^ intOutArray)
    {
        intOutArray->Data[0].strName = ref new String(L"test1.jpg");
        intOutArray->Data[0].strPath = ref new String(L"c:\\temp");
        intOutArray->Data[1].strName = ref new String(L"test2.jpg");
        intOutArray->Data[1].strPath = ref new String(L"c:\\temp");
    }
};
Run Code Online (Sandbox Code Playgroud)

然后我在C#按钮中使用TestOutStructArray函数点击如下.

    CTestWinRT myNative = new CTestWinRT();
    private void btnTestClick(object sender, RoutedEventArgs e)
    {
        Item[] items = new Item[2];
        myNative.TestOutStructArray(items);
    }
Run Code Online (Sandbox Code Playgroud)

该函数正常工作,items数组可以通过调试窗口查看值是否正确.

现在,我想在value struct中添加一个字节数组,如下所示.

public value struct Item
{
    String^ strName; …
Run Code Online (Sandbox Code Playgroud)

c# windows-runtime c++-cx winprt

6
推荐指数
1
解决办法
3231
查看次数

如何使用Python将RGB565字节数组转换为RGB888字节数组?

根据我对RGB888 到 RGB565 的问题,我想做 RGB565 到 RGB888,这是我的测试代码,但是我在转换为 RGB888 字节数组时陷入困境。

import numpy as np
np.random.seed(42)
im = np.random.randint(0,256,(1,4,2), dtype=np.uint8)

# >>> im.nbytes
# 8
# >>> im
# array([[[102, 220],
#        [225,  95],
#        [179,  61],
#        [234, 203]]], dtype=uint8)

# Make components of RGB888
R8 = (im[...,0] & 0xF8).astype(np.uint32) << 8
G8 = (im[...,0] & 0x07).astype(np.uint32) << 5 | (im[...,1] & 0xE0).astype(np.uint32)
B8 = (im[...,1] & 0x1F).astype(np.uint32)
RGB888 = R8 | G8 | B8

# >>> RGB888.nbytes
# …
Run Code Online (Sandbox Code Playgroud)

python rgb numpy

2
推荐指数
1
解决办法
2051
查看次数