Note that there are some explanatory texts on larger screens.

plurals
  1. PODrawing Scale Image from rectangle
    primarykey
    data
    text
    <p>I am writing a delivery program for my final exam for my college on c++. I've downloaded a hd googlemaps screenshot but I have a big problem to draw it on my panel. I create a rectangle as a zoom, to draw just that portion of the image. But my code doesn't seem to be doing that. I need to draw the rectangle on my panel as a scale image of the real picture, cause I will be doing zoom, and moving the map as google maps, so I need to control the size of the rectangle. When I run this code, it just shows half of the image.</p> <pre><code>anchoImagen = PB_Mapa-&gt;Width/zoom; // zoom=1 altoImagen = PB_Mapa-&gt;Height/zoom; Graphics ^g = this-&gt;P_Mapa-&gt;CreateGraphics(); int gWidth = (int)g-&gt;VisibleClipBounds.Width; int gHeight = (int)g-&gt;VisibleClipBounds.Height; BufferedGraphicsContext ^espacioBuffer = BufferedGraphicsManager::Current; // Colocamos el tamaño máximo del Buffer // el +1 es para evitar errores de memoria. espacioBuffer-&gt;MaximumBuffer = System::Drawing::Size( gWidth + 1, gHeight + 1 ); // Creamos un canvas dentro del espacio del buffer utilizando el canvas // del formulario BufferedGraphics ^buffer = espacioBuffer-&gt;Allocate(g, Drawing::Rectangle(0, 0, gWidth, gHeight)); buffer-&gt;Graphics-&gt;Clear(Color::White); // Declaramos un rectangulo con las dimensiones del pedazo del sprite a utilizar Bitmap^ imgTransparente = gcnew Bitmap( PB_Mapa-&gt;Image); Drawing::Rectangle porcionAUsar = Drawing::Rectangle(x,y,anchoImagen,altoImagen); // Dibujamos la imagen en la posicion buffer-&gt;Graphics-&gt;DrawImage(imgTransparente, 0,0, porcionAUsar, GraphicsUnit::Pixel); buffer-&gt;Render(g); // Limpiamos la memoria reservada delete buffer; delete espacioBuffer; delete g; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload