C++ :: SDL Rotating Images Function

Jun 9, 2013

Since SDL doesn't have it's own function for rotating images and I'm tired of storing multiple angles of the same sprite in a file, I created my own function for doing so:

//XY Class
class XY {
public:
XY(){}
XY(float x, float y);

[Code] ....

The problem is while Spin does spin the surface correctly, some pixels are rotated to the same new position so gaps appear in the returned surface. I need a way of filling in the gaps so the returned image looks better. A link to a program I made that uses this function is below so you can see the problem that I'm talking about. [URL] ....

I currently use SDL 1.2. Could my problem be fixed if I used 2.0? For example, does SDL 2.0 have a built in function for rotating surfaces?

View 3 Replies


ADVERTISEMENT

C++ :: Quaternion For Rotating Vectors

Dec 28, 2013

I try to use quaternion to rotate one(and later more!) 3d-vectors in a general manner.

i read in wikipedia, that the general calculation goes with:

vector_rot = quaternion * vector * quaternion_compl.conj.

I used the class of irrlicht [URL] .... to do the calculations.

there is no premade function in this class to rotate vectors through this quaternions, so i just tried to it this way:

irr::core::vector3df v1(1,0,0);
irr::core::quaternion a1(2,3,4,6);
a1.normalize();
irr::core::vector3df result2(a1.X*v1.X*(-a1.X),a1.Y*v1.Y*(- a1.Y),a1.Z*v1.Z*(-a1.Z));

result2 should then be the rotated vector, but it does not work. i dont know how to explicitely write down the rotation specification in this topic.

View 7 Replies View Related

C++ :: Rotating Pixel Field

Apr 21, 2014

I wrote a script that generates n random pixel positions and draws them to the screen. Works well. Now i tried to rotate them. Rotating does work too. But it does not work as i planned it.

paramters 'angle' and 'timestep' work somehow, but not as they should do. the function 'move' is supposed to rotate the pixelfield 'angle' degrees in a given direction, addicted to the 'timestep' parameter. 'timestep' is needed time for drawing in one single game loop.

angle_step = timestep * angle
// x
ppdPoint[i]->x =
pRotationPoint->x + cos(angel_step) * (ppdPoint[i]->x - pRotationPoint->x) - sin(angel_step) * (ppdPoint[i]->y - pRotationPoint->y);
// y
ppdPoint[i]->y =
pRotationPoint->y + sin(angel_step) * (ppdPoint[i]->x - pRotationPoint->x) + cos(angel_step) * (ppdPoint[i]->y - pRotationPoint->y);

rotation point is the middle of the screen. when i set angle to 10 it should rotate 10 degrees / second. Instead it's rotating very very fast and all stars are moving nearer to the center of the screen, so after x rounds there is just 1 pixel left in the middle of the screen. there is a kind of gravition.I'm working with SDL2. What I did find out:

FPS is <= 60, 'cause of the 'SDL_RENDERER_PRESENTVSYNC' flag. When i skip that flag, for any reason the 'gravition' would take more time. FPS is <= 1400 then, 'though i got a natural game loop (i hope):

while(pBuild->getExecuteFlag())
{
pBuild->draw();
pBuild->update(time_dif, pTimeWindow->TimeStampB);
time_dif = (pTimeWindow->TimeStampB - pTimeWindow->TimeStampA);
time_dif *= 0.001;
pTimeWindow->TimeStampA = pTimeWindow->TimeStampB;
pTimeWindow->TimeStampB = SDL_GetTicks();

pBuild->count_fps(pTimeWindow->TimeStampB);
}

So maybe (timestep * angle) isn't the right way?

View 13 Replies View Related

C++ :: Rotating A Circular Disk?

Aug 30, 2013

Any algorithm or function to rotate a displayed circle. To turn it 360 degrees like a car-tire. (It's needed to turn a turn-table in a model-railrod control program) .....

View 14 Replies View Related

C :: Rotating Array And Assigning It To Different Variables

Feb 3, 2013

I have a problem with rotating an array and assigning it to different variables. This is wat i have done.

Code:

#include<stdio.h>#include<stdlib.h>
#include<conio.h>
#include<math.h>
int n[16],a[16],n1[16],n2[16],n3[16],n4[16],n5[16],n6[16],n7[16],n8[16],n9[16],n10[16],n11[16],n12[16],n13[16],n14[16],n15[16],n16[16], c=0;
int x[16],i,j,k;
int rotate();

[code]....

View 4 Replies View Related

C++ :: Images Don't Display?

Oct 6, 2013

My code is:

#include <iostream>
#include <string>
#include <cstdlib>

[Code]....

The problem is that the images don't display and the window doesn't respond.

View 5 Replies View Related

C :: Library For Loading Images In PNG?

Jan 29, 2015

What's the best performance library for loading images in PNG?

View 5 Replies View Related

C :: How To Import Images In Program

Feb 21, 2013

I want to import images in my program and what function I will use.

Compiler: Turboc 3.0

View 2 Replies View Related

C++ :: How Does SDL Load Bitmap Images

Apr 8, 2013

I don't mean how do I load a bmp, I mean how does SDL manage to do this?

View 2 Replies View Related

C++ :: Some Algorithms For Compressing Images?

Feb 16, 2014

RLE(Run Length Encoding)
using namespace std;
class Bitwriter{
private:

[Code]....

View 1 Replies View Related

C++ :: Read Images From Database

May 3, 2013

I have a database of images and I want to store paths of all those images to a text file (lets say "images.txt"). I can then use this text file in c++ to extract images one by one by using getline() in a loop.

I don't know how to store image paths to a text file.

View 4 Replies View Related

C# :: How To Store Images In Folder

Nov 24, 2014

I want to store the images in folder.... but I don't know how to do it

View 7 Replies View Related

C++ :: Can Integrate Images Into Program?

Sep 10, 2013

The question is pretty simple. I'd like to integrate an image into a C++ program.

View 11 Replies View Related

C/C++ :: How To Send Many Images Through Socket

Jun 25, 2012

I have written a socket witch send an image 256x256 and now i want to send many images and i don't know what loop to write to make the socket after have sent the first image to send another and not to write the same program many times for every image ......

this is the part that read the binary image

if( !(fp=fopen("Anemos.bmp","rb"))) {
            printf("Unable to load bin file: %s...
","Anemos.bmp");

[Code] ....

View 2 Replies View Related

Visual C++ :: How To Read Images In GDI Or GDI+

Jul 3, 2014

I am working on application to work with images. How to open/read images, whether it is jpeg, png, bmp or tiff and get it to bitmap. Is there some universal command for this or I will need more commands, every time testing the extension or format and then to use different method to read the image? Best would be to do it automatically, but I don't know such command.

View 8 Replies View Related

C++ :: How To Assign A Rectangle To Images

Apr 26, 2012

I am making a game Pong, and have been struggling with the collision aspect between the baal hitting off the paddle. I have created a Class, to draw a rectangle, to work with collision however I dont know how to assign the rectangle to the images of the ball and paddle.

#include "stdafx.h"
#include <iostream>
#include <time.h>
#include <vector>
#include <cmath>
#include "gwin.h"
const int NUMBEROFBALLS = 1;

[Code] .....

View 1 Replies View Related

C++ :: Extract Some Images From ADF Files

Jul 31, 2013

Its to extract some images from .adf files, I have had it working about 2 years ago but now i cant figure out the right directory.

Code:

using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
namespace ADFReader{
class Program {
public static int ApplyOffset(int data, int offset)
[Code] ...

The main problem is

Code:
static void Main(string[] args) {
foreach (string file in Directory.GetFiles(@"data", "*.adf")) ;
{
byte[] bytes = File.ReadAllBytes(file);

[Code] .....

View 1 Replies View Related

C++ :: Compile Images (PNG Files) Into Application

Jun 19, 2014

I am currently coding a 2D game in Visual Studio 2013. All of the .png graphics are saved in an absolute directory (for example, "C:/gfx/example.png"). Although this works for testing the application on my own system, I would one day like to release it (although it won't be commercial, as I am just learning). I could put all the of the image files in a relative folder, but I do not like the idea of my graphics being out in the open like that.

Is it possible to compile these images into the application itself? I had been researching resource files on Google, but I am still not completely sure if this is what I need to be using. Even if it is, I am using the express version of VS, so I do not have access to the editor. If resource files are what I am looking for, do I have to purchase an upgraded version of Visual Studio, or can I use another editor?

View 9 Replies View Related

C++ :: Transfer Files (mainly Images) Between 2 Computers?

Oct 1, 2014

I need to transfer files(mainly images) between 2 computers using their RAM with some kind of FTP. I'm using C++. I guess it's pretty a lot to explain so if you have a clear and detailed articles/videos

View 8 Replies View Related

C# :: Manipulating Images Colors With ColorMatrix?

Feb 6, 2015

I found this elegant looking code on the net that claims to be able to manipulate an images colors using ColorMatrix.

When I run it, it does nothing! I used the code exactly as is with no editing, except to feed it my own image to do its work.

private void ApplySaturation(float saturation) {
float rWeight = 0.3086f;
float gWeight = 0.6094f;
float bWeight = 0.0820f;
float a = (1.0f - saturation) * rWeight + saturation;

[code].....

View 8 Replies View Related

C# :: Store Images In Database As Well As In Folder

Nov 10, 2014

storing images in database as well as in folder...Images are loaded FROM URL...and after that i want to display Images from folder which is in given below code: but this code is not running...it shows sql connection problem.....but connection is perfect...This code runs properly but it doesn't shows the images from folder...and It doesn't save the images...

using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;

[code]....

View 2 Replies View Related

C Sharp :: How To Add Forward And Back Images

Feb 14, 2013

I want to change this code in c#.net.. But I am unable to do this.. i get error when i tried to session in some variable and when try to + it.

Code id (
Dim A As Integer = Session("Id")  
        p.Value = A + 1)

complete code is
cmd.CommandType = Data.CommandType.StoredProcedure
        cmd.CommandText = "[Netx_Image]"  
        Dim p As New SqlParameter

[Code] .....

View 1 Replies View Related

C++ :: Save Images In Database Or File System?

Aug 22, 2014

Which is best option to save images in database or file system, I am developing c++ server client app. I want to save the images in server using file system or database. I am confusing to choose which option?

View 5 Replies View Related

C# :: Displaying Multiple Images And Adding Sales To Them?

Aug 28, 2014

My application requires the user to add sales to images, this is done by displaying the image for the GUI, and then the user would add sales using that images ID which is brought in from the database.

In part this is 2 questions, first question is what is the best way to generate a List for use when adding the sales to the database. The List would need multiple strings for each sale. So for example:

Image 1 (Sale)

- JPG ID
- Product ID
- Product Quantity

So i'm going to assume i'm best creating a new instance of a custom class for each sale, and then add each instance to a List<Sale>?

public class Sale
{
public int SaleID { get; set; }
public int JpgID { get; set; }
public int SaleQty { get; set; }
}

Then I need a decent way to update this List with the GUI controls. So maybe get the JPG ID and set name of the Sale Class Instance to the ID, in this way its unique and I can update that instance when it comes to increasing the sale of a product or decreasing it.

Second part comes to the design of the GUI of adding sales, when I made this using HTML/PHP that was easier. It looked something like this:

If I wrote some code to generate that kind of design again in C# it going to require many Controls, wouldn't that be a bit intensive on the system? I just want something which looks great but also functions good.

At some point I'm going to switch to WPF, but I just need to get a working prototype working now which my client can use, and then update it when I have more time as I have got other Web Related projects that need doing, so at the moment WPF is out of the question.

View 2 Replies View Related

C/C++ :: How To Randomize Images In Multiple Picture Boxes

May 9, 2014

Here's what i'm searching for: I have a form with 3 pictureBoxes (pictureBox1,2,3). The form also contains one button.

What I want is that when the user clicks the button (so button_click event) that the 3 pictureBoxes each show a different picture. And when I click the button again again 3 different pictures will load.

I already found out that I need to make an arraylist for the pictures (there are about 100 pictures). A System.Random
to select random images. But I have absolutely no clue on how to write this code.

View 5 Replies View Related

C Sharp :: Images Search From Database Using Sessions

Feb 14, 2013

I am facing a problem which is that when i search image from database then it just shows last image which is stored in the database. My code is

private void Images()  {  
            SqlConnection con = new SqlConnection("Data Source=chusman-pc;
Initial Catalog=Hotel_Management;Integrated Security=True");
            con.Open();  
            SqlCommand com = new SqlCommand();

[Code] ....

I call this function at SelectedIndexChanged of dropbox..

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved