标签: resize

调整模板对象的矢量大小时出错

我试图创建一个模板对象的矢量矢量.当我尝试调整内部向量的大小时,错误发生,我无法做出错误消息的头部或尾部.我不知道从何处获取HashTable :: Item :: Item.有什么建议?

/usr/include/c++/4.4.6/bits/stl_vector.h(552):错误:没有构造函数的实例"HashTable :: Item :: Item [with Key = int,Value = Varvalue]"匹配参数列表调整大小(size_type __new_size,value_type __x = value_type())

     detected during:
       instantiation of "void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type={size_t={unsigned long}}, std::vector<_Tp, _Alloc>::value_type) [with _Tp=HashTable<int, Varvalue>::Item, _Alloc=std::allocator<HashTable<int, Varvalue>::Item>]" at line 118 of "main.cc"
Run Code Online (Sandbox Code Playgroud)

这是相关代码:

#define VECLEN 16
class Varvalue
{
public:
        char data[32];
};

template class HashTable { private: class Item { public: bool valid; Key key; Value value; Item *next;
Item(const Key k, const Value v, Item *b = 0, bool …

c++ hash templates resize vector

0
推荐指数
1
解决办法
1267
查看次数

使用保留质量的php调整图片大小

我使用以下方法来调整图像大小:

 private function newDim($maxHeight, $maxWidth, $height, $width) {

        if(($width / $height) >= ($maxWidth / $maxHeight)){
                $nw = $maxWidth;
                $nh = $height * ($maxWidth / $width);
                $nx = round(abs($maxHeight - $nh) / 2);
                $ny = 0 ;
        }else {
            // by height
                $nw = $width*($maxHeight/$height);
                $nh = $maxHeight;
                $nx = 0;
                $ny = round(abs($maxWidth - $nw) / 2); ;
        }

        return array($nw,$nh,$nx,$ny);
    }
Run Code Online (Sandbox Code Playgroud)

之后我想保存这个图像.对于这种情况,我使用这种方法:

 public function upload($file_param_name) {
        $file_name = $_FILES[$file_param_name]['name'];
        $source_file_path = $_FILES[$file_param_name]['tmp_name'];
        $$this->ext = pathinfo($file_name, PATHINFO_EXTENSION);
        $ext = 'jpg'; …
Run Code Online (Sandbox Code Playgroud)

php resize image

0
推荐指数
1
解决办法
2221
查看次数

Python NumPy没有正确调整大小

为什么这段代码不起作用?我无法让这个numpy数组正确调整大小.

import numpy
a = numpy.zeros((10,10))
a[3,2] = 8
a.resize((5,5))
if a[3,2] == 8:
    print "yay"
else:
    print "not working"
raw_input()
Run Code Online (Sandbox Code Playgroud)

python arrays resize numpy

0
推荐指数
1
解决办法
1712
查看次数

JPanel内部的JPanel

我试图让一个JPanel出现在另一个JPanel中。当前,JPanel位于外部JFrame中,并与我的其他JFrame一起加载。我希望JPanel位于另一个JPanel中,以便该程序不会打开两个不同的窗口。

这是一张图片:

图片

我想要在主游戏框架内放置文本日志的小型JPanel。我尝试将面板添加到面板中panel.add(othePanel)。我尝试将其添加到JFrame中frame.add(otherPanel)。它只会覆盖其他所有内容,并为其提供黑色背景。

如何添加面板,调整大小和移动面板?

编辑:

那就是我想要的聊天框。

那就是我想要的聊天框。

班级代码:

不在课堂上。

public static JPanel panel;
public static JTextArea textArea = new JTextArea(5, 30);
public static JTextField userInputField = new JTextField(30);

public static void write(String message) {
    Chatbox.textArea.append("[Game]: " + message + "\n");
    Chatbox.textArea.setCaretPosition(Chatbox.textArea.getDocument()
            .getLength());
    Chatbox.userInputField.setText("");
}

public Chatbox() {
    panel = new JPanel();
    panel.setPreferredSize(new Dimension(220, 40));
    panel.setBackground(Color.BLACK);

    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setPreferredSize(new Dimension(380, 100));
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setEditable(false);
    scrollPane
            .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    userInputField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String …
Run Code Online (Sandbox Code Playgroud)

java swing resize jpanel jframe

0
推荐指数
1
解决办法
1424
查看次数

缩放背景图像,使其始终保持纵横比并保持居中

我想设置一个网页背景图像,以便与浏览器窗口一起缩放,这样它就不会失去原有的宽高比(变得拉伸),从而图像本身基本保持居中.在窗口达到足够小的尺寸后,我希望图像在左侧和右侧都溢出(消失),而不是仅在右侧,因为默认情况下图像是绝对定位的.

这是我现在正在做的一个例子:http://jsfiddle.net/S59EW/2/

#background img {
  position: absolute;
  min-height:100%;
  width: 100%;
  height: auto;
  top: 0;
  left: 0;
}
Run Code Online (Sandbox Code Playgroud)

(图片必须位于一个div内,因为我正在使用的一些javascript适用于它.)

如果您调整jsfiddle窗口的大小,您将看到只有在窗口不太高时图像才会保持其宽高比.然后垂直拉伸图像.

如果你删除"高度:自动"你会得到相同的东西,除了图像停止在某一点后调整大小并消失在右/底侧而不是在顶部/左侧.

#background img {
  position: absolute;
  min-height:100%;
  width: 100%;
  top: 0;
  left: 0;
}
Run Code Online (Sandbox Code Playgroud)

所以,我需要:

背景图像始终占据整个窗口而没有滚动条.图像始终保持纵横比.在某个浏览器大小阈值之后,图像溢出到左侧和右侧,使其基本保持居中.

感谢大家

html css scaling background resize

0
推荐指数
1
解决办法
1万
查看次数

初始化后,在空字符串中添加字符

只是好奇我将如何添加一个字母或字符预先存在string.

这是我想要做的,

我正在取一个密钥及其密文并减去它们的值(存储在arraylist中)以找到明文值(我得到一个int,然后使用它来查找arraylist中的String值)然后继续这样做两个字符串中的每个字母(密码和密钥).

这是可能的,还是我必须使用substring这些或类似的东西.

任何关于如何做到这一点的建议,或者对我最初的问题的答案都非常感谢!

谢谢,

java string resize

0
推荐指数
2
解决办法
5245
查看次数

仅调整大图像的大小

我的应用程序中有一堆(非常)​​大图像.为了使它们适合我的ImageView和相应的Image控件,我使用以下XAML:

<Image Name="imageEdit" Stretch="Uniform" />
Run Code Online (Sandbox Code Playgroud)

现在,当使用大图像时,这会非常有效,因为它们会自动缩小.然而,当显示小图像时,它们被缩放得更高并因此变得模糊.

有没有办法可以防止这种情况发生,只有那些图像调整大小,否则实际上会到达Image控件的边界后面?

c# wpf scaling resize image

0
推荐指数
1
解决办法
995
查看次数

响应式JS - 调整窗口大小时出现问题

我有一些JavaScript,如果屏幕大小超过900px我只想运行.所以我有这个:

if (document.documentElement.clientWidth > 900) {
 $('.menu-item-2477').hover(

 function () {
     $('.menu-item-2477 ul').css({
         display: 'block'
     });
     $('.menu-item-2477 ul').animate({
         height: '100px'
     }, 200);
 },

 function () {
     $('.menu-item-2477 ul').animate({
         height: '0px',
     }, 200, function () {
         $('.menu-item-2477 ul').css({
             display: 'none'
         });
     });
 });
}
Run Code Online (Sandbox Code Playgroud)

这在加载页面时工作正常,但如果更改窗口大小,则忽略if语句.我知道我应该做一些调整大小的功能,比如将整个内容包装起来

$(window).resize(function(){ }
Run Code Online (Sandbox Code Playgroud)

但是当我尝试它时,这不起作用.那么在调整窗口大小后我该怎么做呢?

javascript jquery resize responsive-design

0
推荐指数
1
解决办法
110
查看次数

在一个.php中使用标题('Content-type:image/png')和echo"<html>"

我想用imagecreatefromjpeg,imagecreatetruecolor,imagecopyresizedimagejpeg同时利用的echo "<html><body>";等等...

出于某种原因,我"The image could not be displayed because there were errors on the page"直到我评论出来header('Content-type: image/png');然后我才得到一张破碎图片的照片,就像一张撕裂的页面.

我所看到的只是我header('Content-type: image/png');在同一个.php文件中不能和html.如果是这样的话,任何人都可以告诉我如何调整缩略图库的图像,同时仍然在.php文件中有html?

提前致谢.

html php resize header

0
推荐指数
1
解决办法
7万
查看次数

Android:调整图像宽度和高度

我正在创建一个从网址下载图像的应用程序,将它们保存在设备上,之后必须将它们加载到具有固定大小的ImageView中.对于下载和保存文件我没有问题但是当我尝试在ImageView中设置图像时我有一个致命的错误,因为我的ImageView图像很大(我认为......).

这是xml文件:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ff9f9f"
android:layout_margin="2dip"
android:padding="2dip">

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#ff9f9f"
    android:layout_margin="2dip"
    android:padding="2dip">

    <TextView
        android:id="@+id/notizieTitolo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/immagineNotizie"
        android:text="Titolo"
        android:textColor="#6b71f1"
        android:textSize="20dip"
        android:layout_margin="2dip" />

    <TextView
        android:id="@+id/notizieSottoTitolo"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/immagineNotizie"
        android:text="SottoTitolo"
        android:textSize="15dip" 
        android:layout_margin="2dip"/>

    <ImageView
        android:background="@drawable/icona"
        android:id="@+id/immagineNotizie"
        android:layout_width="100dip"
        android:layout_height="100dip"
        android:layout_margin="2dip" />

</RelativeLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

是一个带有ImageView的简单布局,一个位于ImageView右侧的TextView和一个TextView

重要的是ImageView with和height.设置为100dip(如果我计算2dip为保证金).

这个类的代码,图像保存在Bitmap中.

public class Notizia {
    String url;
    String titolo;
    String sottoTitolo;
    String nomeImmaginSalvata;
    Bitmap immagine;

public Notizia(String tit, String sottoTit, Bitmap imm, String lk){
    titolo = tit;
    sottoTitolo = sottoTit;
    immagine = …
Run Code Online (Sandbox Code Playgroud)

android resize image bitmap

0
推荐指数
1
解决办法
1966
查看次数