⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 image.tex

📁 Wxpython Implemented on Windows CE, Source code
💻 TEX
📖 第 1 页 / 共 4 页
字号:

\wxheading{See also}

\helpref{wxImageHandler}{wximagehandler},
\helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}


\membersection{wxImage::InsertHandler}\label{wximageinserthandler}

\func{static void}{InsertHandler}{\param{wxImageHandler*}{ handler}}

Adds a handler at the start of the static list of format handlers.

\docparam{handler}{A new image format handler object. There is usually only one instance
of a given handler class in an application session.}

\wxheading{See also}

\helpref{wxImageHandler}{wximagehandler}


\membersection{wxImage::IsTransparent}\label{wximageistransparent}

\constfunc{bool}{IsTransparent}{\param{int }{x}, \param{int }{y}, \param{unsigned char}{ threshold = $128$}}

Returns \true if the given pixel is transparent, i.e. either has the mask
colour if this image has a mask or if this image has alpha channel and alpha
value of this pixel is strictly less than \arg{threshold}.


\membersection{wxImage::LoadFile}\label{wximageloadfile}

\func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}, \param{int}{ index = -1}}

\func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}}

Loads an image from a file. If no handler type is provided, the library will
try to autodetect the format.

\func{bool}{LoadFile}{\param{wxInputStream\&}{ stream}, \param{long}{ type}, \param{int}{ index = -1}}

\func{bool}{LoadFile}{\param{wxInputStream\&}{ stream}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}}

Loads an image from an input stream.

\wxheading{Parameters}

\docparam{name}{Name of the file from which to load the image.}

\docparam{stream}{Opened input stream from which to load the image. Currently, the stream must support seeking.}

\docparam{type}{One of the following values:

\twocolwidtha{5cm}%
\begin{twocollist}
\twocolitem{{\bf wxBITMAP\_TYPE\_BMP}}{Load a Windows image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_GIF}}{Load a GIF image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_JPEG}}{Load a JPEG image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_PCX}}{Load a PCX image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Load a PNG image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_PNM}}{Load a PNM image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_TIF}}{Load a TIFF image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Load a XPM image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).}
\twocolitem{{\bf wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).}
\twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).}
\twocolitem{{\bf wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.}
\end{twocollist}}

\docparam{mimetype}{MIME type string (for example 'image/jpeg')}

\docparam{index}{Index of the image to load in the case that the image file contains multiple images.
This is only used by GIF, ICO and TIFF handlers. The default value (-1) means
"choose the default image" and is interpreted as the first image (index=0) by
the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.}

\wxheading{Remarks}

Depending on how wxWidgets has been configured, not all formats may be available.

Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to get the
hotspot for loaded cursor file:
\begin{verbatim}
    int hotspot_x = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
    int hotspot_y = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);

\end{verbatim}

\wxheading{Return value}

true if the operation succeeded, false otherwise. If the optional index parameter is out of range,
false is returned and a call to wxLogError() takes place.

\wxheading{See also}

\helpref{wxImage::SaveFile}{wximagesavefile}

\pythonnote{In place of a single overloaded method name, wxPython
implements the following methods:\par
\indented{2cm}{\begin{twocollist}
\twocolitem{{\bf LoadFile(filename, type)}}{Loads an image of the given
type from a file}
\twocolitem{{\bf LoadMimeFile(filename, mimetype)}}{Loads an image of the given
mimetype from a file}
\end{twocollist}}
}

\perlnote{Methods supported by wxPerl are:\par
\begin{itemize}
\item{bitmap->LoadFile( name, type )}
\item{bitmap->LoadFile( name, mimetype )}
\end{itemize}
}



\membersection{wxImage::Ok}\label{wximageok}

\constfunc{bool}{Ok}{\void}

Returns true if image data is present.


\membersection{RGBValue::RGBValue}\label{rgbvaluergbvalue}

\func{}{RGBValue}{\param{unsigned char }{r = 0}, \param{unsigned char }{g = 0}, \param{unsigned char }{b = 0}}

Constructor for RGBValue, an object that contains values for red, green and blud which
represent the value of a color. It is used by \helpref{wxImage::HSVtoRGB}{wximagehsvtorgb}
and \helpref{wxImage::RGBtoHSV}{wximagergbtohsv}, which
converts between HSV color space and RGB color space.

\pythonnote{use wxImage\_RGBValue in wxPython}


\membersection{wxImage::RGBtoHSV}\label{wximagergbtohsv}

\func{wxImage::HSVValue}{RGBtoHSV}{\param{const RGBValue\& }{rgb}}

Converts a color in RGB color space to HSV color space.


\membersection{wxImage::RemoveHandler}\label{wximageremovehandler}

\func{static bool}{RemoveHandler}{\param{const wxString\& }{name}}

Finds the handler with the given name, and removes it. The handler
is not deleted.

\docparam{name}{The handler name.}

\wxheading{Return value}

true if the handler was found and removed, false otherwise.

\wxheading{See also}

\helpref{wxImageHandler}{wximagehandler}


\membersection{wxImage::Mirror}\label{wximagemirror}

\constfunc{wxImage}{Mirror}{\param{bool}{ horizontally = true}}

Returns a mirrored copy of the image. The parameter {\it horizontally}
indicates the orientation.


\membersection{wxImage::Replace}\label{wximagereplace}

\func{void}{Replace}{\param{unsigned char}{ r1}, \param{unsigned char}{ g1}, \param{unsigned char}{ b1},
\param{unsigned char}{ r2}, \param{unsigned char}{ g2}, \param{unsigned char}{ b2}}

Replaces the colour specified by {\it r1,g1,b1} by the colour {\it r2,g2,b2}.


\membersection{wxImage::Rescale}\label{wximagerescale}

\func{wxImage \&}{Rescale}{\param{int}{ width}, \param{int}{ height}}

Changes the size of the image in-place by scaling it: after a call to this function,
the image will have the given width and height.

Returns the (modified) image itself.

\wxheading{See also}

\helpref{Scale}{wximagescale}


\membersection{wxImage::Resize}\label{wximageresize}

\func{wxImage \&}{Resize}{\param{const wxSize\&}{ size}, \param{const wxPoint&}{ pos}, \param{int}{ red = -1}, \param{int}{ green = -1}, \param{int}{ blue = -1}}

Changes the size of the image in-place without scaling it by adding either a border
with the given colour or cropping as necessary. The image is pasted into a new
image with the given {\it size} and background colour at the position {\it pos}
relative to the upper left of the new image. If {\it red = green = blue = -1}
then use either the  current mask colour if set or find, use, and set a
suitable mask colour for any newly exposed areas.

Returns the (modified) image itself.

\wxheading{See also}

\helpref{Size}{wximagesize}


\membersection{wxImage::Rotate}\label{wximagerotate}

\func{wxImage}{Rotate}{\param{double}{ angle}, \param{const wxPoint\& }{rotationCentre},
 \param{bool}{ interpolating = true}, \param{wxPoint*}{ offsetAfterRotation = NULL}}

Rotates the image about the given point, by {\it angle} radians. Passing true
to {\it interpolating} results in better image quality, but is slower. If the
image has a mask, then the mask colour is used for the uncovered pixels in the
rotated image background. Else, black (rgb 0, 0, 0) will be used.

Returns the rotated image, leaving this image intact.


\membersection{wxImage::RotateHue}\label{wximagerotatehue}

\func{void}{RotateHue}{\param{double}{ angle}}

Rotates the hue of each pixel in the image by {\it angle}, which is a double in
the range of -1.0 to +1.0, where -1.0 corresponds to -360 degrees and +1.0 corresponds
to +360 degrees.


\membersection{wxImage::Rotate90}\label{wximagerotate90}

\constfunc{wxImage}{Rotate90}{\param{bool}{ clockwise = true}}

Returns a copy of the image rotated 90 degrees in the direction
indicated by {\it clockwise}.


\membersection{wxImage::SaveFile}\label{wximagesavefile}

\constfunc{bool}{SaveFile}{\param{const wxString\& }{name}, \param{int}{ type}}

\constfunc{bool}{SaveFile}{\param{const wxString\& }{name}, \param{const wxString\&}{ mimetype}}

Saves an image in the named file.

\constfunc{bool}{SaveFile}{\param{const wxString\& }{name}}

Saves an image in the named file. File type is determined from the extension of the
file name. Note that this function may fail if the extension is not recognized! You
can use one of the forms above to save images to files with non-standard extensions.

\constfunc{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{int}{ type}}

\constfunc{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{const wxString\&}{ mimetype}}

Saves an image in the given stream.

\wxheading{Parameters}

\docparam{name}{Name of the file to save the image to.}

\docparam{stream}{Opened output stream to save the image to.}

\docparam{type}{Currently these types can be used:

\twocolwidtha{5cm}%
\begin{twocollist}
\twocolitem{{\bf wxBITMAP\_TYPE\_BMP}}{Save a BMP image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_JPEG}}{Save a JPEG image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Save a PNG image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_PCX}}{Save a PCX image file (tries to save as 8-bit if possible, falls back to 24-bit otherwise).}
\twocolitem{{\bf wxBITMAP\_TYPE\_PNM}}{Save a PNM image file (as raw RGB always).}
\twocolitem{{\bf wxBITMAP\_TYPE\_TIFF}}{Save a TIFF image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Save a XPM image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_ICO}}{Save a Windows icon file (ICO) (the size may be up to 255 wide by 127 high. A single image is saved in 8 colors at the size supplied).}
\twocolitem{{\bf wxBITMAP\_TYPE\_CUR}}{Save a Windows cursor file (CUR).}
\end{twocollist}}

\docparam{mimetype}{MIME type.}

\wxheading{Return value}

true if the operation succeeded, false otherwise.

\wxheading{Remarks}

Depending on how wxWidgets has been configured, not all formats may be available.

Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to set the
hotspot before saving an image into a cursor file (default hotspot is in
the centre of the image):
\begin{verbatim}
    image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, hotspotX);
    image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, hotspotY);

\end{verbatim}

\wxheading{See also}

\helpref{wxImage::LoadFile}{wximageloadfile}

\pythonnote{In place of a single overloaded method name, wxPython
implements the following methods:\par
\indented{2cm}{\begin{twocollist}
\twocolitem{{\bf SaveFile(filename, type)}}{Saves the image using the given
type to the named file}
\twocolitem{{\bf SaveMimeFile(filename, mimetype)}}{Saves the image using the given
mimetype to the named file}
\end{twocollist}}
}

\perlnote{Methods supported by wxPerl are:\par
\begin{itemize}
\item{bitmap->SaveFile( name, type )}
\item{bitmap->SaveFile( name, mimetype )}
\end{itemize}
}


\membersection{wxImage::Scale}\label{wximagescale}

\constfunc{wxImage}{Scale}{\param{int}{ width}, \param{int}{ height}}

Returns a scaled version of the image. This is also useful for
scaling bitmaps in general as the only other way to scale bitmaps
is to blit a wxMemoryDC into another wxMemoryDC.

It may be mentioned that the GTK port uses this function internally
to scale bitmaps when using mapping modes in wxDC.

Example:

\begin{verbatim}
    // get the bitmap from somewhere
    wxBitmap bmp = ...;

    // rescale it to have size of 32*32
    if ( bmp.GetWidth() != 32 || bmp.GetHeight() != 32 )
    {
        wxImage image = bmp.ConvertToImage();
        bmp = wxBitmap(image.Scale(32, 32));

        // another possibility:
        image.Rescale(32, 32);
        bmp = image;
    }

\end{verbatim}

\wxheading{See also}

\helpref{Rescale}{wximagerescale}


\membersection{wxImage::Size}\label{wximagesize}

\constfunc{wxImage}{Size}{\param{const wxSize\&}{ size}, \param{const wxPoint&}{ pos}, \param{int}{ red = -1}, \param{int}{ green = -1}, \param{int}{ blue = -1}}

Returns a resized version of this image without scaling it by adding either a border
with the given colour or cropping as necessary. The image is pasted into a new
image with the given {\it size} and background colour at the position {\it pos}
relative to the upper left of the new image. If {\it red = green = blue = -1}
then use either the current mask colour if set or find, use, and set a
suitable mask colour for any newly exposed areas.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -