Hello,
I need to some help in reversing an 2-dimensional array. I am working
with gif images and I am trying to make the mirror image. I was
hoping that someone could help give me a headstart in how I can
accomplish this. Also, I don't know the the size of the array before
hand as the image can be any size. I already have the my read and
write gif functions working, but I just need to know how to reverse
the contents.
Thanks for your help in advance. 4 5964
Kevin wrote: Hello,
I need to some help in reversing an 2-dimensional array. I am working with gif images and I am trying to make the mirror image. I was hoping that someone could help give me a headstart in how I can accomplish this. Also, I don't know the the size of the array before hand as the image can be any size. I already have the my read and write gif functions working, but I just need to know how to reverse the contents.
Post some code. At least enough to know the type and layout of your array.
--
WW aka Attila
"Kevin" <ke*********@ms n.com> wrote in message
news:e9******** *************** ***@posting.goo gle.com... Hello,
I need to some help in reversing an 2-dimensional array. I am working with gif images and I am trying to make the mirror image. I was hoping that someone could help give me a headstart in how I can accomplish this. Also, I don't know the the size of the array before hand as the image can be any size. I already have the my read and write gif functions working, but I just need to know how to reverse the contents.
Thanks for your help in advance.
Well, suppose you have a realtiny bitmap .. 4x4 pixels, and
0 1 2 3
4 5 6 7
8 9 a b
c d e f
are the fields (each field represents one pixel). The mirror image would
have to look like this:
3 2 1 0
7 6 5 4
b a 9 8
f e d c
Now if you did not know the dimension, the image could be 8x2 pixel as
well:
0 1 2 3 4 5 6 7
8 9 a b c d e f
and the mirrored image for that is:
7 6 5 4 3 2 1 0
f e d c b a 9 8
If now you put all rows into one single row (one row after the other,
the way they are stored in memory) you will find that the mirrored image for
the 4x4 image and the 8x2 image are not the same. So first, you better find
out the size of that image. For the reversing task, you could use
std::reverse for each row. Also note that each field above represents one
pixel of the image (this includes all possible bytes needed to represent
that pixel). You have to keep that in mind when using std::reverse,
otherwise your colors will get messed up.
hth
--
jb
(replace y with x if you want to reply by e-mail)
Kevin wrote: Hello,
I need to some help in reversing an 2-dimensional array. I am working with gif images and I am trying to make the mirror image. I was hoping that someone could help give me a headstart in how I can accomplish this. Also, I don't know the the size of the array before hand as the image can be any size. I already have the my read and write gif functions working, but I just need to know how to reverse the contents.
std::reverse(r. begin(), r.end()) for each row in the array? Or is there
something particular about GIF (as opposed to PPM) that won't let you do
this?
/david
--
Andre, a simple peasant, had only one thing on his mind as he crept
along the East wall: 'Andre, creep... Andre, creep... Andre, creep.'
-- unknown
Kevin wrote: Hello,
I need to some help in reversing an 2-dimensional array. I am working with gif images and I am trying to make the mirror image. I was hoping that someone could help give me a headstart in how I can accomplish this. Also, I don't know the the size of the array before hand as the image can be any size. I already have the my read and write gif functions working, but I just need to know how to reverse the contents.
Thanks for your help in advance.
I've always found that assembly languages are best at bit manipulation.
Your processor may have some instructions that will be more efficient
than C++ code.
I suggest you ask about image transformations in a graphics newsgroup.
They will probably have better algorithms there.
You could treat the graphic as a matrix and apply a transformation
to it.
You could copy the bits, row by row, in a reverse order to another
image or matrix.
You could write a multi-bit swap routine and apply it to each row.
.....
--
Thomas Matthews
C++ newsgroup welcome message: http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.l earn.c-c++ faq: http://www.raos.demon.uk/acllc-c++/faq.html
Other sites: http://www.josuttis.com -- C++ STL Library book This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nathan Rose |
last post by:
Here's my problem. I am reading from a text file using this:
if (!file_exists($file))
{
echo "Don't exist\n";
return false;
}
$fd = @fopen($file, 'r');
if (!is_resource($fd))
|
by: Wilfredo |
last post by:
I have 25 numbers coming up from 1 to 25, now I want it to
go from 25 to 1 with array.reverse. I get a reverse is not
a member of array. Help
|
by: Charles Law |
last post by:
I thought this had come up before, but I now cannot find it.
I have a byte array, such as
Dim a() As Byte = {1, 2, 3, 4}
I want to convert this to an Int32 = 01020304 (hex).
If I use BitConverter, I get 04030201.
|
by: Ivar |
last post by:
Hi guys - So basically I am trying to implement a function that
converts an int to a string, but it is not working for some reason -
any thoughts? My function, intToStr, is shown below. I'm just trying to
implement this to gain practice with c-style strings.
#include<iostream>
#include"testString.h"
int main(int argc, char* argv) {
char* c2 = new char;
|
by: dru |
last post by:
Problem:
Reversing the elements of an array involves swapping the corresponding elements of the array: the first with the last, the second with the next to the last, and so on, all the way to the middle of the array.
Given an array a , an int variable n containing the number of elements in a , and two other int variables, k and temp , write a loop that reverses the elements of the array.
Do not use any other variables besides ...
| |
by: Superman859 |
last post by:
Hello everyone. Heads up - c++ syntax is killing me. I do quite well
in creating a Java program with very few syntax errors, but I get them
all over the place in c++. The smallest little things get me, which
brings me to...
I'm trying to create a program that gets a string from standard input
and then manipulates it a little bit. It has to be a char array and
not use string from the library.
Here are my prototypes:
|
by: arnuld |
last post by:
i have created a solutions myself. it compiles without any trouble
and runs but it prints some strange characters. i am not able to find
where is the trouble.
--------------------------------- PROGRAMME
--------------------------------
/* K&R2 section 1.9
exercise 1.19
|
by: Tarique |
last post by:
/**
A palindrome is a number that is the same whether it is read from
left-to-right or right-to-left. For example, 121 and 34543 are both
palindromes. It turns out that nearly every integer can be transformed
into a palindrome by reversing its digits and adding it to the original
number. If that does not create a palindrome, add the reverse of the new
number to itself. A palindrome is created by repeating the process of
reversing the...
|
by: Ravi4raj |
last post by:
Hi all, Here i have to know is thr any way to sort the array according to thr Bit Reverse..
for Example:
If we take the Array size of 256,then the Sorting Should be like below.
a = a
a = a // bit lenght = Bits required for 256.
.
;
exapmle for Bit Reversing if for 256 9 bits are Needed to store the Value ,
so Bit reversal of 1,
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |